SCurve: fix calculate_path bugs and add comprehensive tests#32730
Merged
Conversation
ae85879 to
a8e9db7
Compare
Contributor
|
IamPete1
approved these changes
Apr 10, 2026
Contributor
|
Is this observable in flight? |
Contributor
|
Hi @tpwrules, my understanding from a quick chat with Leonard is that it is observable as an overshoot as the vehicle transitions from one waypoint to the next. |
Contributor
Author
I have tired to excite this but it is really difficult. I believe I have seen it once but then could not replicate it. I have spent some time trying but have not been succsessful. |
a8e9db7 to
ffc489b
Compare
andyp1per
reviewed
Apr 13, 2026
| // add to constant velocity segment to end at the correct position | ||
| const float dP = MAX(0.0f, Pend - segment[SEG_DECEL_END].end_pos); | ||
| const float t15 = dP / segment[SEG_CONST].end_vel; | ||
| const float t15 = is_positive(segment[SEG_CONST].end_vel) ? dP / segment[SEG_CONST].end_vel : 0.0f; |
Contributor
There was a problem hiding this comment.
It's 124 bytes for doing the same check multiple times. You could probably avoid the impact of this by using a function
Contributor
Author
There was a problem hiding this comment.
Good suggestion. Addressed in a follow up PR:
rmackay9
approved these changes
Apr 14, 2026
Contributor
|
This has been included in 4.7.0-beta4. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix three bugs in SCurve::calculate_path and set_speed_max, add tests
that cover all code paths, and clean up float literal consistency.
Fixes #32724
Bug fixes:
should be (L - 4V0tj). The old formula inflated the allowed
acceleration when V0 > 0, producing invalid motion profiles.
when the path is too short for the initial velocity.
exponent as 0, making powf always return 1.0 instead of the cube
root. This disabled the velocity-based jerk time limit.
segment[SEG_CONST].end_vel in four places.
Tests:
inputs per path near transitions and midpoints.
verify total distance, final velocity, final acceleration, and that
velocity, acceleration, and jerk limits are not exceeded.
Cleanup:
implicit double-to-float conversions.
Classification & Testing (check all that apply and add your own)