From 7d7076205376cb4a0356195b9501fc0c6c74dba5 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Tue, 6 Sep 2022 19:51:21 +0100 Subject: [PATCH] Copter: use pilot_desired_throttle rather than limit_throttle_out in stabilize and acro. --- ArduCopter/mode_acro.cpp | 10 ++++------ ArduCopter/mode_stabilize.cpp | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ArduCopter/mode_acro.cpp b/ArduCopter/mode_acro.cpp index 31f55665c4..03160ab2a0 100644 --- a/ArduCopter/mode_acro.cpp +++ b/ArduCopter/mode_acro.cpp @@ -28,21 +28,21 @@ void ModeAcro::run() motors->set_desired_spool_state(AP_Motors::DesiredSpoolState::THROTTLE_UNLIMITED); } - bool limit_throttle_out = false; + float pilot_desired_throttle = get_pilot_desired_throttle(); switch (motors->get_spool_state()) { case AP_Motors::SpoolState::SHUT_DOWN: // Motors Stopped attitude_control->reset_target_and_rate(true); attitude_control->reset_rate_controller_I_terms(); - limit_throttle_out = true; + pilot_desired_throttle = 0.0f; break; case AP_Motors::SpoolState::GROUND_IDLE: // Landed attitude_control->reset_target_and_rate(); attitude_control->reset_rate_controller_I_terms_smoothly(); - limit_throttle_out = true; + pilot_desired_throttle = 0.0f; break; case AP_Motors::SpoolState::THROTTLE_UNLIMITED: @@ -66,9 +66,7 @@ void ModeAcro::run() } // output pilot's throttle without angle boost - attitude_control->set_throttle_out(limit_throttle_out ? 0 : get_pilot_desired_throttle(), - false, - copter.g.throttle_filt); + attitude_control->set_throttle_out(pilot_desired_throttle, false, copter.g.throttle_filt); } bool ModeAcro::init(bool ignore_checks) diff --git a/ArduCopter/mode_stabilize.cpp b/ArduCopter/mode_stabilize.cpp index e634743b36..5dbf2d4bdc 100644 --- a/ArduCopter/mode_stabilize.cpp +++ b/ArduCopter/mode_stabilize.cpp @@ -32,21 +32,21 @@ void ModeStabilize::run() motors->set_desired_spool_state(AP_Motors::DesiredSpoolState::THROTTLE_UNLIMITED); } - bool limit_throttle_out = false; + float pilot_desired_throttle = get_pilot_desired_throttle(); switch (motors->get_spool_state()) { case AP_Motors::SpoolState::SHUT_DOWN: // Motors Stopped attitude_control->reset_yaw_target_and_rate(); attitude_control->reset_rate_controller_I_terms(); - limit_throttle_out = true; + pilot_desired_throttle = 0.0f; break; case AP_Motors::SpoolState::GROUND_IDLE: // Landed attitude_control->reset_yaw_target_and_rate(); attitude_control->reset_rate_controller_I_terms_smoothly(); - limit_throttle_out = true; + pilot_desired_throttle = 0.0f; break; case AP_Motors::SpoolState::THROTTLE_UNLIMITED: @@ -66,7 +66,5 @@ void ModeStabilize::run() attitude_control->input_euler_angle_roll_pitch_euler_rate_yaw(target_roll, target_pitch, target_yaw_rate); // output pilot's throttle - attitude_control->set_throttle_out(limit_throttle_out ? 0 : get_pilot_desired_throttle(), - true, - g.throttle_filt); + attitude_control->set_throttle_out(pilot_desired_throttle, true, g.throttle_filt); }