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

chore(autoware_motion_utils): add error handling, adapt to edge cases, and use an iterator-based algorithm #209

Closed
wants to merge 1 commit into from

Conversation

yhisaki
Copy link
Contributor

@yhisaki yhisaki commented Feb 20, 2025

Description

  1. If given index of points are out of range, make it to throw out_of_range exception.
  2. If src_idx is end, return 0.0 as a distance.
  3. Use the range based accumulation algorithm.

Related links

How was this PR tested?

Unit Test

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

…, and use an iterator-based algorithm

Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
Copy link

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@yhisaki yhisaki added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Feb 20, 2025
Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 45.94%. Comparing base (4cb18f5) to head (55a9a96).
Report is 56 commits behind head on main.

Files with missing lines Patch % Lines
...de/autoware/motion_utils/trajectory/trajectory.hpp 83.33% 0 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
differential 45.94% <83.33%> (?)
total ?

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -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));

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.

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?

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?

Copy link
Contributor

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.

@xmfcx xmfcx added the type:improvement Proposed enhancement label Feb 26, 2025
@yhisaki yhisaki closed this Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:improvement Proposed enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants