From de1ade8eb883aa2d6cccebc687471252409d244c Mon Sep 17 00:00:00 2001 From: Marco Hauswirth <58551738+haumarco@users.noreply.github.com> Date: Fri, 7 Feb 2025 05:47:32 +0100 Subject: [PATCH] sensors/vehicle_air_data: only trigger the sensor fallback when the baro_fault flag switches from 0 -> 1 --- src/modules/sensors/vehicle_air_data/VehicleAirData.cpp | 6 +++++- src/modules/sensors/vehicle_air_data/VehicleAirData.hpp | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/sensors/vehicle_air_data/VehicleAirData.cpp b/src/modules/sensors/vehicle_air_data/VehicleAirData.cpp index 24996c84da..263a56090f 100644 --- a/src/modules/sensors/vehicle_air_data/VehicleAirData.cpp +++ b/src/modules/sensors/vehicle_air_data/VehicleAirData.cpp @@ -200,7 +200,7 @@ void VehicleAirData::Run() } if (estimator_status_flags_updated && _selected_sensor_sub_index >= 0 && _selected_sensor_sub_index == uorb_index - && estimator_status_flags.cs_baro_fault) { + && estimator_status_flags.cs_baro_fault && !_last_status_baro_fault) { _priority[uorb_index] = 1; // 1 is min priority while still being enabled } @@ -225,6 +225,10 @@ void VehicleAirData::Run() } } + if (estimator_status_flags_updated) { + _last_status_baro_fault = estimator_status_flags.cs_baro_fault; + } + // check for the current best sensor int best_index = 0; _voter.get_best(time_now_us, &best_index); diff --git a/src/modules/sensors/vehicle_air_data/VehicleAirData.hpp b/src/modules/sensors/vehicle_air_data/VehicleAirData.hpp index ce7a8a117c..a0bdb4007d 100644 --- a/src/modules/sensors/vehicle_air_data/VehicleAirData.hpp +++ b/src/modules/sensors/vehicle_air_data/VehicleAirData.hpp @@ -126,6 +126,8 @@ private: float _air_temperature_celsius{20.f}; // initialize with typical 20degC ambient temperature + bool _last_status_baro_fault{false}; + DEFINE_PARAMETERS( (ParamFloat) _param_sens_baro_qnh, (ParamFloat) _param_sens_baro_rate