From f7df3795e6ca092e413fd8daac7c8c95aa4aed20 Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Sat, 25 Nov 2023 23:38:25 +0000 Subject: [PATCH] Plane: ignore invalid pilot throttle --- ArduPlane/reverse_thrust.cpp | 8 ++++++++ ArduPlane/servos.cpp | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ArduPlane/reverse_thrust.cpp b/ArduPlane/reverse_thrust.cpp index f64f37b276d6b3..16dc514b547646 100644 --- a/ArduPlane/reverse_thrust.cpp +++ b/ArduPlane/reverse_thrust.cpp @@ -125,6 +125,10 @@ bool Plane::have_reverse_thrust(void) const */ float Plane::get_throttle_input(bool no_deadzone) const { + if (!rc().has_valid_input()) { + // Return 0 if there is no valid input + return 0.0; + } float ret; if (no_deadzone) { ret = channel_throttle->get_control_in_zero_dz(); @@ -143,6 +147,10 @@ float Plane::get_throttle_input(bool no_deadzone) const */ float Plane::get_adjusted_throttle_input(bool no_deadzone) const { + if (!rc().has_valid_input()) { + // Return 0 if there is no valid input + return 0.0; + } if ((plane.channel_throttle->get_type() != RC_Channel::ControlType::RANGE) || (flight_option_enabled(FlightOptions::CENTER_THROTTLE_TRIM)) == 0) { return get_throttle_input(no_deadzone); diff --git a/ArduPlane/servos.cpp b/ArduPlane/servos.cpp index 85fe2689f3765a..e583df8e7eccdf 100644 --- a/ArduPlane/servos.cpp +++ b/ArduPlane/servos.cpp @@ -547,9 +547,7 @@ void Plane::set_servos_controlled(void) control_mode == &mode_fbwa || control_mode == &mode_autotune) { // a manual throttle mode - if (!rc().has_valid_input()) { - SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, g.throttle_passthru_stabilize ? 0.0 : MAX(min_throttle,0)); - } else if (g.throttle_passthru_stabilize) { + if (g.throttle_passthru_stabilize) { // manual pass through of throttle while in FBWA or // STABILIZE mode with THR_PASS_STAB set SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, get_throttle_input(true));