add cs_baro_fault to switch to fallback baro if available (#24260)

This commit is contained in:
Marco Hauswirth
2025-01-28 10:37:16 +01:00
committed by GitHub
parent 92b1f51623
commit 4df65c133e
7 changed files with 17 additions and 3 deletions
@@ -141,6 +141,9 @@ void VehicleAirData::Run()
AirTemperatureUpdate();
estimator_status_flags_s estimator_status_flags;
const bool estimator_status_flags_updated = _estimator_status_flags_sub.update(&estimator_status_flags);
bool updated[MAX_SENSOR_COUNT] {};
for (int uorb_index = 0; uorb_index < MAX_SENSOR_COUNT; uorb_index++) {
@@ -196,6 +199,11 @@ void VehicleAirData::Run()
ParametersUpdate(true);
}
if (estimator_status_flags_updated && _selected_sensor_sub_index >= 0 && _selected_sensor_sub_index == uorb_index
&& estimator_status_flags.cs_baro_fault) {
_priority[uorb_index] = 1; // 1 is min priority while still being enabled
}
// pressure corrected with offset (if available)
_calibration[uorb_index].SensorCorrectionsUpdate();
const float pressure_corrected = _calibration[uorb_index].Correct(report.pressure);
@@ -54,6 +54,7 @@
#include <uORB/topics/sensor_baro.h>
#include <uORB/topics/sensors_status.h>
#include <uORB/topics/vehicle_air_data.h>
#include <uORB/topics/estimator_status_flags.h>
using namespace time_literals;
@@ -89,6 +90,8 @@ private:
uORB::Subscription _differential_pressure_sub{ORB_ID(differential_pressure)};
uORB::Subscription _estimator_status_flags_sub{ORB_ID(estimator_status_flags)};
uORB::SubscriptionCallbackWorkItem _sensor_sub[MAX_SENSOR_COUNT] {
{this, ORB_ID(sensor_baro), 0},
{this, ORB_ID(sensor_baro), 1},