From 8e4c5884ec076d09b1c1463b65a6e6fbccf8310f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 12 Dec 2022 15:12:50 +0100 Subject: [PATCH] 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 --- src/modules/commander/UserModeIntention.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/modules/commander/UserModeIntention.cpp b/src/modules/commander/UserModeIntention.cpp index 851f1f772e..62ab871fe8 100644 --- a/src/modules/commander/UserModeIntention.cpp +++ b/src/modules/commander/UserModeIntention.cpp @@ -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) { _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 bool always_allow = force || !isArmed(); @@ -67,6 +62,7 @@ bool UserModeIntention::change(uint8_t user_intended_nav_state, bool allow_fallb } if (allow_change) { + _had_mode_change = true; _user_intented_nav_state = user_intended_nav_state; if (!_health_and_arming_checks.modePreventsArming(user_intended_nav_state)) {