From 3764f377d8716e0e9cfa6c1ba5c4bad7a95fe85c Mon Sep 17 00:00:00 2001 From: Stephen Dade Date: Thu, 24 Oct 2024 21:52:24 +1100 Subject: [PATCH] APM_Control: Correct use of deceleration --- libraries/APM_Control/AR_AttitudeControl.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/APM_Control/AR_AttitudeControl.cpp b/libraries/APM_Control/AR_AttitudeControl.cpp index c537a05868..1262506693 100644 --- a/libraries/APM_Control/AR_AttitudeControl.cpp +++ b/libraries/APM_Control/AR_AttitudeControl.cpp @@ -1058,15 +1058,14 @@ float AR_AttitudeControl::get_desired_speed_accel_limited(float desired_speed, f float AR_AttitudeControl::get_stopping_distance(float speed) const { // get maximum vehicle deceleration - const float accel_max = get_accel_max(); + const float decel_max = get_decel_max(); - // avoid divide by zero - if ((accel_max <= 0.0f) || is_zero(speed)) { + if ((decel_max <= 0.0f) || is_zero(speed)) { return 0.0f; } // assume linear deceleration - return 0.5f * sq(speed) / accel_max; + return 0.5f * sq(speed) / decel_max; } // relax I terms of throttle and steering controllers