From fedc33bdeae24b1b6d0ffb25155da8c674b6fa17 Mon Sep 17 00:00:00 2001 From: jiakun <53556221+ddwolf87@users.noreply.github.com> Date: Fri, 6 Nov 2026 01:53:19 +0800 Subject: [PATCH] fix(sensors): skip baro GNSS offset without baro samples (#29634) Backport of the baro change from #28943 to release/1.18: with a baro publishing at or below SENS_BARO_RATE (e.g. DroneCAN baros), the 50 ms backup run can reach the offset calibration with zero accumulated baro samples, and the _data_sum_count division yields NaN that feeds the baro-GNSS altitude offset LPF. Guard the division the same way as on main (e6db1b3a14), adapted to the release/1.18 subscription (_vehicle_gps_position_sub), which main has since renamed to _vehicle_gnss_sub. Assisted-by: GLM:glm-5.3-flash Signed-off-by: jiakun <53556221+ddwolf87@users.noreply.github.com> --- src/modules/sensors/vehicle_air_data/VehicleAirData.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/sensors/vehicle_air_data/VehicleAirData.cpp b/src/modules/sensors/vehicle_air_data/VehicleAirData.cpp index 13c17b197d5..c15f1cd5775 100644 --- a/src/modules/sensors/vehicle_air_data/VehicleAirData.cpp +++ b/src/modules/sensors/vehicle_air_data/VehicleAirData.cpp @@ -490,7 +490,8 @@ bool VehicleAirData::BaroGNSSAltitudeOffset() sensor_gps_s gps_pos; - if (!_vehicle_gps_position_sub.update(&gps_pos)) { + // no baro samples accumulated yet, leave the GNSS sample for the next run + if ((_data_sum_count[_selected_sensor_sub_index] == 0) || !_vehicle_gps_position_sub.update(&gps_pos)) { return false; }