-
Notifications
You must be signed in to change notification settings - Fork 50
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
chore(autoware_motion_utils): add error handling, adapt to edge cases, and use an iterator-based algorithm #209
Conversation
…, and use an iterator-based algorithm Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #209 +/- ##
===========================================
- Coverage 78.75% 45.94% -32.82%
===========================================
Files 11 40 +29
Lines 193 7705 +7512
Branches 73 5609 +5536
===========================================
+ Hits 152 3540 +3388
- Misses 11 769 +758
- Partials 30 3396 +3366
☔ View full report in Codecov by Sentry. |
@@ -725,11 +726,19 @@ double calcSignedArcLength(const T & points, const size_t src_idx, const size_t | |||
return -calcSignedArcLength(points, dst_idx, src_idx); | |||
} | |||
|
|||
double dist_sum = 0.0; | |||
for (size_t i = src_idx; i < dst_idx; ++i) { | |||
dist_sum += autoware_utils::calc_distance2d(points.at(i), points.at(i + 1)); |
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.
Since at
operation is used for the index, without your change, when there is an out of range index, I guess the error will be thrown.
Let me know if I miss something.
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.
Maybe this is unfair, but could you add a small unit-test?
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.
@PanConChicharron
What do you mean by unfair?
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.
We will stop representing the trajectory as a list of points in the next few months. In this case please clamp the src and dst to within the points size and log the error instead of raising exception.
Description
Related links
How was this PR tested?
Unit Test
Notes for reviewers
None.
Interface changes
None.
Effects on system behavior
None.