-
Notifications
You must be signed in to change notification settings - Fork 650
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
refactor(motion_velocity_smoother): change curvature calculation #1638
refactor(motion_velocity_smoother): change curvature calculation #1638
Conversation
a93a2c6
to
d091ddc
Compare
Codecov Report
@@ Coverage Diff @@
## main #1638 +/- ##
=======================================
Coverage 10.38% 10.38%
=======================================
Files 1212 1212
Lines 87402 87402
Branches 20274 20274
=======================================
Hits 9081 9081
Misses 68842 68842
Partials 9479 9479
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brkay54 Thank you for your contribution.
I confirmed it works well in my simulation.
Since it has a long backward path length, we can not see a big difference, but definitely better.
(blue: closest curvature of smoother node in current implementation, red: with this PR)
const auto p0 = getPoint(trajectory.at(i - std::min(idx_dist, i))); | ||
const auto p1 = getPoint(trajectory.at(i)); | ||
const auto p2 = getPoint(trajectory.at(i + std::min(idx_dist, trajectory.size() - 1 - i))); | ||
k_arr.push_back(calcCurvature(p0, p1, p2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The calcCurvature() in autoware_utils lib throws an exception when these points are too close. Would you add special handling for closed points? Maybe use previous curvature or something.
(Or just keep using try-catch. It is not a nice way though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the error handler, if there is a previous curvature, it push back. Else it push back 0.0. Is it proper way to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
@@ -212,22 +212,31 @@ std::vector<double> calcTrajectoryCurvatureFrom3Points( | |||
|
|||
// calculate curvature by circle fitting from three points | |||
std::vector<double> k_arr; | |||
for (size_t i = idx_dist; i < trajectory.size() - idx_dist; ++i) { | |||
// for first point curvature = 0; | |||
k_arr.push_back(0.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brkay54 For the first and last points, how about taking a copy from the next/previous value?
std::vector<double> k_arr(trajectory.size(), 0.0);
...
// compute k for each index
...
k_arr.at(0) = k_arr.at(1);
k_arr.back() = k_arr.at(trajectory.size() - 2);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Berkay Karaman <berkay@leodrive.ai>
Signed-off-by: Berkay Karaman <berkay@leodrive.ai>
Signed-off-by: Berkay Karaman <berkay@leodrive.ai>
942cb87
to
a786a62
Compare
…r4#1638) * refactor(motion_velocity_smoother): change curvature calculation Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * add error handler for too close points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * take copy for first and last points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix Signed-off-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…r4#1638) * refactor(motion_velocity_smoother): change curvature calculation Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * add error handler for too close points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * take copy for first and last points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix Signed-off-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…r4#1638) * refactor(motion_velocity_smoother): change curvature calculation Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * add error handler for too close points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * take copy for first and last points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix Signed-off-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…owarefoundation#1638) * refactor(motion_velocity_smoother): change curvature calculation Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * add error handler for too close points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * take copy for first and last points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix Signed-off-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…r4#1638) * refactor(motion_velocity_smoother): change curvature calculation Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * add error handler for too close points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix * take copy for first and last points Signed-off-by: Berkay Karaman <berkay@leodrive.ai> * ci(pre-commit): autofix Signed-off-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: Berkay Karaman <berkay@leodrive.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Berkay berkay@leodrive.ai
Description
Related: #1071 (comment)
While curvature is calculating, the function copied first and last curvature points (that can not calculate due to distance) from next or before points that can be calculated so it causes curvature with high error.
Pre-review checklist for the PR author
The PR author must check the checkboxes below when creating the PR.
In-review checklist for the PR reviewers
The PR reviewers must check the checkboxes below before approval.
Post-review checklist for the PR author
The PR author must check the checkboxes below before merging.
After all checkboxes are checked, anyone who has write access can merge the PR.