From 96904636f3dd288d39963b547fcbbf3892e703af Mon Sep 17 00:00:00 2001 From: Mahima Yoga Date: Fri, 10 Oct 2025 19:59:26 +0200 Subject: [PATCH] commander: prevent setting nav_state to takeoff after disarming (#25735) * commander: prevent setting nav_state after disarming to takeoff * wrap in function --- src/modules/commander/UserModeIntention.cpp | 3 ++- src/modules/commander/UserModeIntention.hpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/commander/UserModeIntention.cpp b/src/modules/commander/UserModeIntention.cpp index 556bddbd18..2085995d6c 100644 --- a/src/modules/commander/UserModeIntention.cpp +++ b/src/modules/commander/UserModeIntention.cpp @@ -77,7 +77,8 @@ bool UserModeIntention::change(uint8_t user_intended_nav_state, ModeChangeSource // Special case termination state: even though this mode prevents arming, // still don't switch out of it after disarm and thus store it in _nav_state_after_disarming. - if (!_health_and_arming_checks.modePreventsArming(user_intended_nav_state) + if ((!_health_and_arming_checks.modePreventsArming(user_intended_nav_state) + && !isTakeOffIntended(user_intended_nav_state)) || user_intended_nav_state == vehicle_status_s::NAVIGATION_STATE_TERMINATION) { _nav_state_after_disarming = user_intended_nav_state; } diff --git a/src/modules/commander/UserModeIntention.hpp b/src/modules/commander/UserModeIntention.hpp index cfb4e3998b..e37bf467b1 100644 --- a/src/modules/commander/UserModeIntention.hpp +++ b/src/modules/commander/UserModeIntention.hpp @@ -91,6 +91,7 @@ public: private: bool isArmed() const { return _vehicle_status.arming_state == vehicle_status_s::ARMING_STATE_ARMED; } + bool isTakeOffIntended(uint8_t user_intented_nav_state) const {return user_intented_nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF || user_intented_nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_VTOL_TAKEOFF;} const vehicle_status_s &_vehicle_status; const HealthAndArmingChecks &_health_and_arming_checks;