From eb880a2657bf38886ef941cd789b3512e6d35d9c Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Mon, 26 Oct 2020 16:09:44 +0900 Subject: [PATCH] AP_Scripting: copter-wall-climber fix for climb rate limiting --- libraries/AP_Scripting/examples/copter-wall-climber.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Scripting/examples/copter-wall-climber.lua b/libraries/AP_Scripting/examples/copter-wall-climber.lua index ecfc37f4b7..0028776c30 100644 --- a/libraries/AP_Scripting/examples/copter-wall-climber.lua +++ b/libraries/AP_Scripting/examples/copter-wall-climber.lua @@ -202,8 +202,11 @@ function update() end -- calculate acceleration limited climb rate - climb_rate = math.min(climb_rate_target, climb_rate + climb_rate_chg_max, climb_rate_max) - climb_rate = math.max(climb_rate_target, climb_rate - climb_rate_chg_max, -climb_rate_max) + if (climb_rate_target >= climb_rate) then + climb_rate = math.min(climb_rate_target, climb_rate + climb_rate_chg_max, climb_rate_max) + else + climb_rate = math.max(climb_rate_target, climb_rate - climb_rate_chg_max, -climb_rate_max) + end end end