From a5c55c3fbdf4f8135b744144768a2d658dd742ae Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sat, 7 May 2016 12:20:48 +0900 Subject: [PATCH] Copter: fix get_non_takeoff_throttle The throttle_mid parameter (for historic reason) is interpreted as a value that includes throttle_min. This means we must subtract the throttle_min value from it when converting it to a throttle in the 0 to 1 range. --- ArduCopter/Attitude.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ArduCopter/Attitude.cpp b/ArduCopter/Attitude.cpp index 1513027533..7edf573e19 100644 --- a/ArduCopter/Attitude.cpp +++ b/ArduCopter/Attitude.cpp @@ -199,7 +199,9 @@ float Copter::get_pilot_desired_climb_rate(float throttle_control) // get_non_takeoff_throttle - a throttle somewhere between min and mid throttle which should not lead to a takeoff float Copter::get_non_takeoff_throttle() { - return (((float)g.throttle_mid/1000.0f)/2.0f); + // ensure mid throttle is set within a reasonable range + g.throttle_mid = constrain_int16(g.throttle_mid,g.throttle_min+50,700); + return MAX(0,g.throttle_mid-g.throttle_min) / ((float)(1000-g.throttle_min) * 2.0f); } float Copter::get_takeoff_trigger_throttle()