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

RJD-1337 Fix getQuadraticAccelerationDuration returning negative duration #1411

Merged
merged 6 commits into from
Oct 31, 2024

Conversation

gmajrobotec
Copy link
Contributor

Description

Abstract

Function getQuadraticAccelerationDuration can return a negative duration. It is possible because getQuadraticAccelerationDurationWithConstantJerk is being invoked if-and-only-if v and target_speed are almost equal, which does not seem correct. This part of the code also seems incongruent with the comments in code below:

// While quadratic acceleration, the entity does not reached the target speed.
if (std::abs(v - target_speed) >= 0.01) {
return duration;
}
// While quadratic acceleration, the entity reached the target speed.
else {
return getQuadraticAccelerationDurationWithConstantJerk(
target_speed, constraints, current_twist, current_accel);
}

double v = getVelocityWithConstantJerk(
current_twist, current_accel, -constraints.max_deceleration_rate, duration);
// While quadratic acceleration, the entity does not reached the target speed.
if (std::abs(v - target_speed) >= 0.01) {
return duration;
}
// While quadratic acceleration, the entity reached the target speed.
else {
return getQuadraticAccelerationDurationWithConstantJerk(
target_speed, constraints, current_twist, current_accel);
}

Details

Comparison if (std::abs(v - target_speed) >= 0.01) in getQuadraticAccelerationDuration is changed to if (v < target_speed) ensuring return duration is not negative.

References

Jira ticket: internal link

Destructive Changes

There are no destructive changes.

Copy link

github-actions bot commented Oct 3, 2024

Checklist for reviewers ☑️

All references to "You" in the following text refer to the code reviewer.

  • Is this pull request written in a way that is easy to read from a third-party perspective?
  • Is there sufficient information (background, purpose, specification, algorithm description, list of disruptive changes, and migration guide) in the description of this pull request?
  • If this pull request contains a destructive change, does this pull request contain the migration guide?
  • Labels of this pull request are valid?
  • All unit tests/integration tests are included in this pull request? If you think adding test cases is unnecessary, please describe why and cross out this line.
  • The documentation for this pull request is enough? If you think adding documents for this pull request is unnecessary, please describe why and cross out this line.

@gmajrobotec gmajrobotec added bump patch If this pull request merged, bump patch version of the scenario_simulator_v2 wait for regression test and removed wait for regression test labels Oct 4, 2024
@gmajrobotec gmajrobotec marked this pull request as ready for review October 9, 2024 07:51
Copy link

sonarcloud bot commented Oct 31, 2024

@hakuturu583 hakuturu583 merged commit 1cbbbc5 into master Oct 31, 2024
13 checks passed
@github-actions github-actions bot deleted the RJD-1337/getQuadraticAccelerationDuration branch October 31, 2024 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch If this pull request merged, bump patch version of the scenario_simulator_v2 wait for regression test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants