Skip to content

Commit

Permalink
sensors/vehicle_air_data: only trigger the sensor fallback when the b…
Browse files Browse the repository at this point in the history
…aro_fault flag switches from 0 -> 1
  • Loading branch information
haumarco authored Feb 7, 2025
1 parent fd175d6 commit de1ade8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/sensors/vehicle_air_data/VehicleAirData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/modules/sensors/vehicle_air_data/VehicleAirData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class VehicleAirData : public ModuleParams, public px4::ScheduledWorkItem

float _air_temperature_celsius{20.f}; // initialize with typical 20degC ambient temperature

bool _last_status_baro_fault{false};

DEFINE_PARAMETERS(
(ParamFloat<px4::params::SENS_BARO_QNH>) _param_sens_baro_qnh,
(ParamFloat<px4::params::SENS_BARO_RATE>) _param_sens_baro_rate
Expand Down

0 comments on commit de1ade8

Please sign in to comment.