Skip to content

Commit

Permalink
APM_Control: Correct use of deceleration
Browse files Browse the repository at this point in the history
  • Loading branch information
stephendade authored and rmackay9 committed Nov 4, 2024
1 parent 4c9da02 commit 3764f37
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions libraries/APM_Control/AR_AttitudeControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3764f37

Please sign in to comment.