mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 15:38:52 +08:00
fix commander: need to check for valid mode change even if already the same
Fixes the following case: - user intention set to X - failsafe triggers, mode = Y - can_run for X becomes false - user tries to switch to X -> need to re-evaluate can_run
This commit is contained in:
@@ -43,11 +43,6 @@ UserModeIntention::UserModeIntention(ModuleParams *parent, const vehicle_status_
|
|||||||
bool UserModeIntention::change(uint8_t user_intended_nav_state, bool allow_fallback, bool force)
|
bool UserModeIntention::change(uint8_t user_intended_nav_state, bool allow_fallback, bool force)
|
||||||
{
|
{
|
||||||
_ever_had_mode_change = true;
|
_ever_had_mode_change = true;
|
||||||
_had_mode_change = true;
|
|
||||||
|
|
||||||
if (_user_intented_nav_state == user_intended_nav_state) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always allow mode change while disarmed
|
// Always allow mode change while disarmed
|
||||||
bool always_allow = force || !isArmed();
|
bool always_allow = force || !isArmed();
|
||||||
@@ -67,6 +62,7 @@ bool UserModeIntention::change(uint8_t user_intended_nav_state, bool allow_fallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allow_change) {
|
if (allow_change) {
|
||||||
|
_had_mode_change = true;
|
||||||
_user_intented_nav_state = user_intended_nav_state;
|
_user_intented_nav_state = user_intended_nav_state;
|
||||||
|
|
||||||
if (!_health_and_arming_checks.modePreventsArming(user_intended_nav_state)) {
|
if (!_health_and_arming_checks.modePreventsArming(user_intended_nav_state)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user