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

Added checks for negative discriminants #1420

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

TakanoTaiga
Copy link
Member

Description

This pull request adds checks for negative discriminants before calculating square roots in the longitudinal speed planning logic to prevent invalid operations that could occur when the discriminant is negative.

Abstract

This pull request introduces validation for negative discriminants in the LongitudinalSpeedPlanner to prevent invalid square root calculations during acceleration and deceleration constraint planning.

Background

In the current implementation, the code attempts to compute the square root of a discriminant that can occasionally be negative. This can lead to exceptions and undefined behavior. Adding checks before these calculations ensures stability and prevents such issues.

Details

The changes involve checking if the discriminant is negative before performing a square root operation in both the acceleration and deceleration branches. If the discriminant is negative, a semantic error is thrown to handle the situation appropriately. This fix addresses the problem where the target speed may be too high or too low relative to the acceleration or deceleration rate, leading to negative values in the discriminant.

References

N/A

Destructive Changes

N/A

Known Limitations

N/A

@TakanoTaiga TakanoTaiga added the bump patch If this pull request merged, bump patch version of the scenario_simulator_v2 label Oct 10, 2024
@TakanoTaiga TakanoTaiga self-assigned this Oct 10, 2024
Copy link

github-actions bot commented Oct 10, 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.

@TakanoTaiga TakanoTaiga changed the title Added checks for negative discriminants before sqrt to prevent invali… Added checks for negative discriminants Oct 10, 2024
Copy link

sonarcloud bot commented Oct 10, 2024

@TakanoTaiga TakanoTaiga marked this pull request as ready for review October 10, 2024 08:53
Copy link
Collaborator

@hakuturu583 hakuturu583 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
waiting for regression test.

@hakuturu583 hakuturu583 merged commit 65f4c20 into master Oct 15, 2024
19 checks passed
@github-actions github-actions bot deleted the fix/negative-sqrt-in-planConstraints2 branch October 15, 2024 08:37
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