mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 01:53:33 +08:00
Commander: make low remaining flight time configurable and fix clearing condition (#22863)
* Commander: make low remaining flight time configurable and do not clear - add _ACT param to disable/warning/RTL this feature - publish rtl flight time estimate also in RTL, and thus fix re-validation - make failure message clearer, distinguish from battery low * battery check: add hysteresis for declaring battery_low_remaining_time false again --------- Signed-off-by: Silvan Fuhrer <silvan@auterion.com> Co-authored-by: KonradRudin <98741601+KonradRudin@users.noreply.github.com>
This commit is contained in:
co-authored by
KonradRudin
parent
7fe5ee64fe
commit
00cc68baa1
@@ -365,6 +365,36 @@ FailsafeBase::ActionOptions Failsafe::fromHighWindLimitActParam(int param_value)
|
||||
return options;
|
||||
}
|
||||
|
||||
FailsafeBase::ActionOptions Failsafe::fromRemainingFlightTimeLowActParam(int param_value)
|
||||
{
|
||||
ActionOptions options{};
|
||||
|
||||
options.allow_user_takeover = UserTakeoverAllowed::Always;
|
||||
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;
|
||||
}
|
||||
|
||||
void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
|
||||
const failsafe_flags_s &status_flags)
|
||||
{
|
||||
@@ -444,9 +474,10 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
|
||||
|
||||
CHECK_FAILSAFE(status_flags, geofence_breached, fromGfActParam(_param_gf_action.get()).cannotBeDeferred());
|
||||
|
||||
// Battery
|
||||
// Battery flight time remaining failsafe
|
||||
|
||||
CHECK_FAILSAFE(status_flags, battery_low_remaining_time,
|
||||
ActionOptions(Action::RTL).causedBy(Cause::BatteryLow).clearOn(ClearCondition::OnModeChangeOrDisarm));
|
||||
ActionOptions(fromRemainingFlightTimeLowActParam(_param_com_fltt_low_act.get())));
|
||||
|
||||
if ((_armed_time != 0)
|
||||
&& (time_us < _armed_time + static_cast<hrt_abstime>(_param_com_spoolup_time.get() * 1_s))
|
||||
@@ -457,6 +488,7 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
|
||||
CHECK_FAILSAFE(status_flags, battery_unhealthy, Action::Warn);
|
||||
}
|
||||
|
||||
// Battery low failsafe
|
||||
switch (status_flags.battery_warning) {
|
||||
case battery_status_s::BATTERY_WARNING_LOW:
|
||||
_last_state_battery_warning_low = checkFailsafe(_caller_id_battery_warning_low, _last_state_battery_warning_low,
|
||||
|
||||
@@ -141,6 +141,12 @@ private:
|
||||
Land_mode = 5
|
||||
};
|
||||
|
||||
enum class command_after_remaining_flight_time_low : int32_t {
|
||||
None = 0,
|
||||
Warning = 1,
|
||||
Return_mode = 3
|
||||
};
|
||||
|
||||
static ActionOptions fromNavDllOrRclActParam(int param_value);
|
||||
|
||||
static ActionOptions fromGfActParam(int param_value);
|
||||
@@ -150,6 +156,7 @@ private:
|
||||
static ActionOptions fromQuadchuteActParam(int param_value);
|
||||
static Action fromOffboardLossActParam(int param_value, uint8_t &user_intended_mode);
|
||||
static ActionOptions fromHighWindLimitActParam(int param_value);
|
||||
static ActionOptions fromRemainingFlightTimeLowActParam(int param_value);
|
||||
|
||||
const int _caller_id_mode_fallback{genCallerId()};
|
||||
bool _last_state_mode_fallback{false};
|
||||
@@ -182,7 +189,8 @@ private:
|
||||
(ParamInt<px4::params::COM_LOW_BAT_ACT>) _param_com_low_bat_act,
|
||||
(ParamInt<px4::params::COM_OBL_RC_ACT>) _param_com_obl_rc_act,
|
||||
(ParamInt<px4::params::COM_QC_ACT>) _param_com_qc_act,
|
||||
(ParamInt<px4::params::COM_WIND_MAX_ACT>) _param_com_wind_max_act
|
||||
(ParamInt<px4::params::COM_WIND_MAX_ACT>) _param_com_wind_max_act,
|
||||
(ParamInt<px4::params::COM_FLTT_LOW_ACT>) _param_com_fltt_low_act
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@@ -250,6 +250,11 @@ void FailsafeBase::notifyUser(uint8_t user_intended_mode, Action action, Action
|
||||
events::send(events::ID("commander_failsafe_enter_crit_low_bat_warn"), {events::Log::Emergency, events::LogInternal::Info},
|
||||
"Emergency battery level, land immediately");
|
||||
|
||||
} else if (cause == Cause::RemainingFlightTimeLow) {
|
||||
events::send(events::ID("commander_failsafe_enter_low_flight_time_warn"),
|
||||
{events::Log::Warning, events::LogInternal::Info},
|
||||
"Low remaining flight time, return advised");
|
||||
|
||||
} else {
|
||||
/* EVENT
|
||||
* @description No action is triggered.
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
BatteryLow,
|
||||
BatteryCritical,
|
||||
BatteryEmergency,
|
||||
RemainingFlightTimeLow,
|
||||
|
||||
Count
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user