Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APM_Control: Use deceleration for stopping distance #28442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stephendade
Copy link
Contributor

For Rover, a correction for calculating the stopping distance - it should use deceleration, not acceleration.

Tested in SITL.

@stephendade stephendade marked this pull request as draft October 22, 2024 07:47
@stephendade
Copy link
Contributor Author

Turns out there's a bunch of other parts of Rover that just use acceleration instead of deceleration. Will add them to this PR...

@stephendade
Copy link
Contributor Author

stephendade commented Oct 24, 2024

Digging further into this, the s-curve navigation assumes that the max acceleration and deceleration are the same value.

There's some fairly scary-looking maths in the s-curve navigation that I don't think I'd be able to extend to different acceleration/deceleration values.

So I'll keep this patch to the current fixing of the APM_Control portion of the code. Any flight mode that uses s-curves will continue to use the minimum of (atc_accel_max, atc_decel_max).

Tested in SITL.

@stephendade stephendade marked this pull request as ready for review October 24, 2024 11:00
@peterbarker
Copy link
Contributor

This looks right, but @lthall might have words to add.

@stephendade can you explain the reasoning behind the speed_prev change, please? It's not covered in your comments.

@stephendade
Copy link
Contributor Author

@stephendade can you explain the reasoning behind the speed_prev change, please? It's not covered in your comments.

It appeared to be a (deliberate?) typo/bug. The original if (fabsf(desired_speed) < fabsf(desired_speed) && is_positive(_throttle_decel_max)) would always return false, thus limiting the max speed change to _throttle_accel_max.

I fixed the statement to if (fabsf(desired_speed) < fabsf(speed_prev) && is_positive(_throttle_decel_max)), so the correct value of (_throttle_decel_max, _throttle_accel_max) would be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants