From 75a51c19c73201287bd24b88f66223e5812c71a8 Mon Sep 17 00:00:00 2001 From: Jacob Dahl <37091262+dakejahl@users.noreply.github.com> Date: Thu, 19 Mar 2026 11:24:37 -0800 Subject: [PATCH] fix(commander): arm throttle check for all vehicle types (#26683) Extend the arm throttle safety check to all vehicle types including rovers, which were previously excluded. Unify the two separate throttle checks into a single evaluation at arm-time that accounts for vehicle type and control mode: rovers require centered stick, climb-rate modes require stick at or below center, and manual/stab/acro modes require stick at bottom. --- src/modules/commander/Commander.cpp | 41 +++++++++++++++-------------- src/modules/commander/Commander.hpp | 3 +-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index f423bdf1df..e522090622 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -608,27 +608,29 @@ transition_result_t Commander::arm(arm_disarm_reason_t calling_reason, bool run_ if (run_preflight_checks) { if (_vehicle_control_mode.flag_control_manual_enabled) { - if (_vehicle_control_mode.flag_control_climb_rate_enabled && - !_failsafe_flags.manual_control_signal_lost && _is_throttle_above_center) { + if (!_failsafe_flags.manual_control_signal_lost) { + bool throttle_safe; - mavlink_log_critical(&_mavlink_log_pub, "Arming denied: throttle above center\t"); - events::send(events::ID("commander_arm_denied_throttle_center"), {events::Log::Critical, events::LogInternal::Info}, - "Arming denied: throttle above center"); - tune_negative(true); - return TRANSITION_DENIED; - } + if (_vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROVER) { + // Rovers: center stick = stop, safe to arm near center + throttle_safe = (fabsf(_last_manual_throttle) < 0.2f); - if (!_vehicle_control_mode.flag_control_climb_rate_enabled && - !_failsafe_flags.manual_control_signal_lost && !_is_throttle_low - && ((_vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING) - || (_vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING)) - ) { + } else if (_vehicle_control_mode.flag_control_climb_rate_enabled) { + // Climb-rate modes (AltCtl, PosCtl, etc.): center = hover, safe at or below center + throttle_safe = (_last_manual_throttle <= 0.2f); - mavlink_log_critical(&_mavlink_log_pub, "Arming denied: high throttle\t"); - events::send(events::ID("commander_arm_denied_throttle_high"), {events::Log::Critical, events::LogInternal::Info}, - "Arming denied: high throttle"); - tune_negative(true); - return TRANSITION_DENIED; + } else { + // Manual/Stab/Acro on MC/FW: bottom = no thrust, safe at bottom + throttle_safe = (_last_manual_throttle < -0.8f); + } + + if (!throttle_safe) { + mavlink_log_critical(&_mavlink_log_pub, "Arming denied: throttle not in safe position\t"); + events::send(events::ID("commander_arm_denied_throttle_unsafe"), {events::Log::Critical, events::LogInternal::Info}, + "Arming denied: throttle not in safe position"); + tune_negative(true); + return TRANSITION_DENIED; + } } } else if (calling_reason == arm_disarm_reason_t::stick_gesture @@ -3001,8 +3003,7 @@ void Commander::manualControlCheck() if (manual_control_updated && manual_control_setpoint.valid) { - _is_throttle_above_center = (manual_control_setpoint.throttle > 0.2f); - _is_throttle_low = (manual_control_setpoint.throttle < -0.8f); + _last_manual_throttle = manual_control_setpoint.throttle; if (isArmed()) { // Abort autonomous mode and switch to position mode if sticks are moved significantly diff --git a/src/modules/commander/Commander.hpp b/src/modules/commander/Commander.hpp index e4915fe94d..afb56de5fb 100644 --- a/src/modules/commander/Commander.hpp +++ b/src/modules/commander/Commander.hpp @@ -279,8 +279,7 @@ private: bool _last_overload{false}; bool _mode_switch_mapped{false}; - bool _is_throttle_above_center{false}; - bool _is_throttle_low{false}; + float _last_manual_throttle{-1.f}; bool _arm_tune_played{false}; bool _have_taken_off_since_arming{false};