fix commander: separate state tracking for battery_unhealthy failsafe (#24493)

There is already another check for battery_unhealthy, so a separate state
and ID are required.

Fixes the error:
ERROR [failsafe] BUG: duplicate check for caller_id 74
This commit is contained in:
Beat Küng
2025-03-12 16:46:02 +01:00
committed by GitHub
parent b5e2395982
commit a3c387fa85
2 changed files with 10 additions and 2 deletions
+6 -2
View File
@@ -577,8 +577,12 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
if ((_armed_time != 0)
&& (time_us < _armed_time + static_cast<hrt_abstime>(_param_com_spoolup_time.get() * 1_s))
) {
CHECK_FAILSAFE(status_flags, fd_esc_arming_failure, ActionOptions(Action::Disarm).cannotBeDeferred());
CHECK_FAILSAFE(status_flags, battery_unhealthy, ActionOptions(Action::Disarm).cannotBeDeferred());
_last_state_fd_esc_arming = checkFailsafe(_caller_id_fd_esc_arming, _last_state_fd_esc_arming,
status_flags.fd_esc_arming_failure,
ActionOptions(Action::Disarm).cannotBeDeferred());
_last_state_battery_unhealthy_spoolup = checkFailsafe(_caller_id_battery_unhealthy_spoolup,
_last_state_battery_unhealthy_spoolup, status_flags.battery_unhealthy,
ActionOptions(Action::Disarm).cannotBeDeferred());
}
// Handle fails during the early takeoff phase
@@ -179,6 +179,10 @@ private:
bool _last_state_battery_warning_critical{false};
const int _caller_id_battery_warning_emergency{genCallerId()};
bool _last_state_battery_warning_emergency{false};
const int _caller_id_fd_esc_arming{genCallerId()};
bool _last_state_fd_esc_arming{false};
const int _caller_id_battery_unhealthy_spoolup{genCallerId()};
bool _last_state_battery_unhealthy_spoolup{false};
hrt_abstime _armed_time{0};
bool _was_armed{false};