feat(commander)!: combine battery and bingo fuel failsafe into COM_LOW_BAT_ACT (#29620)

This commit is contained in:
Matthias Grob authored and GitHub committed 2026-11-09 10:22:41 +01:00
1 parent fedc33bdea
commit c6ddbe1499
9 files changed
+132 -84

No files matched your search

+27 -35
View File
@@ -165,6 +165,9 @@ FailsafeBase::ActionOptions Failsafe::fromActuatorFailureActParam(int param_valu
return options;
}
// "battery level" to handle the remaining flight time (Distance-aware return)
static constexpr uint8_t BATTERY_WARNING_DISTANCE_AWARE_RETURN = UINT8_MAX;
FailsafeBase::ActionOptions Failsafe::fromBatteryWarningActParam(int param_value, uint8_t battery_warning)
{
ActionOptions options{};
@@ -187,6 +190,7 @@ FailsafeBase::ActionOptions Failsafe::fromBatteryWarningActParam(int param_value
switch ((LowBatteryAction)param_value) {
case LowBatteryAction::Return:
case LowBatteryAction::ReturnOrLand:
case LowBatteryAction::ReturnOrLandWithoutDistanceAwareReturn:
options.action = Action::RTL;
break;
@@ -210,8 +214,9 @@ FailsafeBase::ActionOptions Failsafe::fromBatteryWarningActParam(int param_value
options.action = Action::RTL;
break;
case LowBatteryAction::ReturnOrLand:
case LowBatteryAction::Land:
case LowBatteryAction::ReturnOrLand:
case LowBatteryAction::ReturnOrLandWithoutDistanceAwareReturn:
options.action = Action::Land;
break;
@@ -221,6 +226,24 @@ FailsafeBase::ActionOptions Failsafe::fromBatteryWarningActParam(int param_value
}
break;
case BATTERY_WARNING_DISTANCE_AWARE_RETURN:
options.action = Action::Warn;
options.cause = Cause::RemainingFlightTimeLow;
switch ((LowBatteryAction)param_value) {
case LowBatteryAction::Return:
case LowBatteryAction::ReturnOrLand:
options.action = Action::RTL;
options.clear_condition = ClearCondition::OnModeChangeOrDisarm;
break;
case LowBatteryAction::Warning:
case LowBatteryAction::Land:
case LowBatteryAction::ReturnOrLandWithoutDistanceAwareReturn:
options.action = Action::Warn;
break;
}
}
return options;
@@ -444,36 +467,6 @@ FailsafeBase::ActionOptions Failsafe::fromParachuteActParam(int param_value)
return options;
}
FailsafeBase::ActionOptions Failsafe::fromRemainingFlightTimeLowActParam(int param_value)
{
ActionOptions options{};
options.allow_user_takeover = UserTakeoverAllowed::Auto;
options.cause = Cause::RemainingFlightTimeLow;
switch (command_after_remaining_flight_time_low(param_value)) {
case command_after_remaining_flight_time_low::None:
options.action = Action::None;
break;
case command_after_remaining_flight_time_low::Warning:
options.action = Action::Warn;
break;
case command_after_remaining_flight_time_low::Return_mode:
options.action = Action::RTL;
options.clear_condition = ClearCondition::OnModeChangeOrDisarm;
break;
default:
options.action = Action::None;
break;
}
return options;
}
FailsafeBase::ActionOptions Failsafe::fromOdidFailActParam(int param_value)
{
ActionOptions options{};
@@ -625,10 +618,6 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
CHECK_FAILSAFE(status_flags, geofence_breached, fromGfActParam(_param_gf_action.get()).cannotBeDeferred());
// Battery flight time remaining failsafe
CHECK_FAILSAFE(status_flags, battery_low_remaining_time,
ActionOptions(fromRemainingFlightTimeLowActParam(_param_com_fltt_low_act.get())));
const hrt_abstime spoolup = static_cast<hrt_abstime>(_param_com_spoolup_time.get() * 1_s);
if ((_armed_time != 0) && (time_us < _armed_time + spoolup)) {
@@ -674,6 +663,9 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
break;
}
// Battery flight time remaining failsafe (Distance-aware return)
CHECK_FAILSAFE(status_flags, battery_low_remaining_time,
ActionOptions(fromBatteryWarningActParam(_param_com_low_bat_act.get(), BATTERY_WARNING_DISTANCE_AWARE_RETURN)));
// Handle fails during spoolup just after arming
if ((_armed_time != 0) && (time_us < _armed_time + spoolup)) {