Skip to content

Commit a3c387f

Browse files
authored
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
1 parent b5e2395 commit a3c387f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/modules/commander/failsafe/failsafe.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,12 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
577577
if ((_armed_time != 0)
578578
&& (time_us < _armed_time + static_cast<hrt_abstime>(_param_com_spoolup_time.get() * 1_s))
579579
) {
580-
CHECK_FAILSAFE(status_flags, fd_esc_arming_failure, ActionOptions(Action::Disarm).cannotBeDeferred());
581-
CHECK_FAILSAFE(status_flags, battery_unhealthy, ActionOptions(Action::Disarm).cannotBeDeferred());
580+
_last_state_fd_esc_arming = checkFailsafe(_caller_id_fd_esc_arming, _last_state_fd_esc_arming,
581+
status_flags.fd_esc_arming_failure,
582+
ActionOptions(Action::Disarm).cannotBeDeferred());
583+
_last_state_battery_unhealthy_spoolup = checkFailsafe(_caller_id_battery_unhealthy_spoolup,
584+
_last_state_battery_unhealthy_spoolup, status_flags.battery_unhealthy,
585+
ActionOptions(Action::Disarm).cannotBeDeferred());
582586
}
583587

584588
// Handle fails during the early takeoff phase

src/modules/commander/failsafe/failsafe.h

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ class Failsafe : public FailsafeBase
179179
bool _last_state_battery_warning_critical{false};
180180
const int _caller_id_battery_warning_emergency{genCallerId()};
181181
bool _last_state_battery_warning_emergency{false};
182+
const int _caller_id_fd_esc_arming{genCallerId()};
183+
bool _last_state_fd_esc_arming{false};
184+
const int _caller_id_battery_unhealthy_spoolup{genCallerId()};
185+
bool _last_state_battery_unhealthy_spoolup{false};
182186

183187
hrt_abstime _armed_time{0};
184188
bool _was_armed{false};

0 commit comments

Comments
 (0)