Commander: windCheck: add COM_WIND_MAX_ACT param to set high wind failsafe action (#21373)

Has options *None where the check is disabled, and *Warning, where only a warning is
published (which replaces the high wind warning from the COM_WIND_WARN limit).

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer authored and GitHub committed 2023-11-06 11:58:21 +01:00
1 parent a29b07fa73
commit 54d26e084a
5 files changed
+98 -16

No files matched your search

+43 -2
View File
@@ -323,6 +323,48 @@ FailsafeBase::Action Failsafe::fromOffboardLossActParam(int param_value, uint8_t
return action;
}
FailsafeBase::ActionOptions Failsafe::fromHighWindLimitActParam(int param_value)
{
ActionOptions options{};
switch (command_after_high_wind_failsafe(param_value)) {
case command_after_high_wind_failsafe::None:
options.action = Action::None;
break;
case command_after_high_wind_failsafe::Warning:
options.action = Action::Warn;
break;
case command_after_high_wind_failsafe::Hold_mode:
options.allow_user_takeover = UserTakeoverAllowed::AlwaysModeSwitchOnly; // ensure the user can escape again
options.action = Action::Hold;
options.clear_condition = ClearCondition::OnModeChangeOrDisarm;
break;
case command_after_high_wind_failsafe::Return_mode:
options.action = Action::RTL;
options.clear_condition = ClearCondition::OnModeChangeOrDisarm;
break;
case command_after_high_wind_failsafe::Terminate:
options.allow_user_takeover = UserTakeoverAllowed::Never;
options.action = Action::Terminate;
options.clear_condition = ClearCondition::Never;
break;
case command_after_high_wind_failsafe::Land_mode:
options.action = Action::Land;
break;
default:
options.action = Action::Warn;
break;
}
return options;
}
void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
const failsafe_flags_s &status_flags)
{
@@ -390,9 +432,8 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
}
}
CHECK_FAILSAFE(status_flags, wind_limit_exceeded,
ActionOptions(Action::RTL).clearOn(ClearCondition::OnModeChangeOrDisarm).cannotBeDeferred());
ActionOptions(fromHighWindLimitActParam(_param_com_wind_max_act.get()).cannotBeDeferred()));
CHECK_FAILSAFE(status_flags, flight_time_limit_exceeded, ActionOptions(Action::RTL).cannotBeDeferred());
// trigger RTL if low position accurancy is detected