mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
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.
This commit is contained in:
parent
2f8ca0ec96
commit
75a51c19c7
@ -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
|
||||
|
||||
@ -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};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user