mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-27 01:50:34 +08:00
fix(failsafe): allow orbit on the first command after a failsafe (#27673)
* fix(failsafe): allow orbit on the first command after a failsafe modifyUserIntendedMode() downgrades a requested Orbit to Loiter when releasing control after an active failsafe action, to avoid silently auto-resuming a stale Orbit intention. It could not distinguish that auto-resume from a fresh, explicit DO_ORBIT the operator sends right after resolving the failsafe: two DO_ORBIT commands where needed to actually re-start an orbit. Now using user_intended_mode_updated signal, the downgrade is skipped when the orbit is explicitely requested. * fix(failsafe): fix ITCM symbol and test names after orbit fix The added modifyUserIntendedMode() parameter changed its mangled name, breaking the ITCM check (fmu-v6xrt, mr-tropic, tropic-community). Update the symbol and rename the two new tests to CamelCase for clang-tidy. * fix(failsafe): suggestion for a simpler approach to solve the divverted Orbit after failsafe problem * fix(failsafe_test): inherit from Failsafe instead of FailsafeBase to not duplicate modifyUserIntendedMode() Also change all test names to consistent camel case. --------- Co-authored-by: Matthias Grob <maetugr@gmail.com>
This commit is contained in:
1 parent
dc2868132b
commit
96038adb6b
2 files changed
+88
-27
No files matched your search
@@ -540,8 +540,7 @@ bool Failsafe::isFailsafeIgnored(uint8_t user_intended_mode, int32_t exception_m
|
||||
}
|
||||
}
|
||||
|
||||
void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
|
||||
const failsafe_flags_s &status_flags)
|
||||
void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state, const failsafe_flags_s &status_flags)
|
||||
{
|
||||
updateArmingState(time_us, state.armed, status_flags);
|
||||
|
||||
@@ -723,8 +722,7 @@ void Failsafe::updateArmingState(const hrt_abstime &time_us, bool armed, const f
|
||||
_was_armed = armed;
|
||||
}
|
||||
|
||||
FailsafeBase::Action Failsafe::checkModeFallback(const failsafe_flags_s &status_flags,
|
||||
uint8_t user_intended_mode) const
|
||||
FailsafeBase::Action Failsafe::checkModeFallback(const failsafe_flags_s &status_flags, uint8_t user_intended_mode) const
|
||||
{
|
||||
Action action = Action::None;
|
||||
|
||||
@@ -767,13 +765,14 @@ FailsafeBase::Action Failsafe::checkModeFallback(const failsafe_flags_s &status_
|
||||
return action;
|
||||
}
|
||||
|
||||
uint8_t Failsafe::modifyUserIntendedMode(Action previous_action, Action current_action,
|
||||
uint8_t user_intended_mode) const
|
||||
uint8_t Failsafe::modifyUserIntendedMode(Action previous_action, Action current_action, uint8_t user_intended_mode) const
|
||||
{
|
||||
// If we switch from a failsafe back into orbit, switch to loiter instead
|
||||
if ((int)previous_action > (int)Action::Warn
|
||||
&& modeFromAction(current_action, user_intended_mode) == vehicle_status_s::NAVIGATION_STATE_ORBIT) {
|
||||
PX4_DEBUG("Failsafe cleared, switching from ORBIT to LOITER");
|
||||
// When a failsafe engages, immediately downgrade Orbit to Loiter so that
|
||||
// if the failsafe later clears without a new explicit mode command the vehicle holds position.
|
||||
if ((int)previous_action <= (int)Action::Warn
|
||||
&& (int)current_action > (int)Action::Warn
|
||||
&& user_intended_mode == vehicle_status_s::NAVIGATION_STATE_ORBIT) {
|
||||
PX4_DEBUG("Failsafe engaged, downgrading ORBIT to LOITER");
|
||||
return vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user