Repository navigation
Cache the last-accessed segment in Path::getPathSegment - #3800
hugogo1998 wants to merge 5 commits into
Conversation
Path::getPathSegment scans path_segments_ from the front on every call. The TOTG integration loop calls it (directly and via getTangent/getConfig/getCurvature) thousands of times per trajectory at monotonically-advancing arc-length positions, so the from-front rescan makes the whole time-parameterization pass O(steps * segments) instead of the O(steps) it could be. Cache the last-found segment and resume the scan from there when the new query position is at or after that segment's start, which is the common case since queries only move forward during integration; fall back to scanning from the front otherwise. Finds the same segment and applies the same position adjustment as before, so output is unchanged. Copy-constructed Paths start with the cache marked invalid, since cache_valid_ isn't in the copy constructor's init list and its default member initializer applies.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Hi @davetcoleman, could you take a look at this PR when you get a chance? Please let me know if I overlooked anything. Thanks. |
marioprats
left a comment
There was a problem hiding this comment.
Looks good, thank you!
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3800 +/- ##
==========================================
+ Coverage 48.92% 49.02% +0.11%
==========================================
Files 735 735
Lines 62684 62729 +45
Branches 7617 7624 +7
==========================================
+ Hits 30663 30748 +85
+ Misses 32021 31981 -40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Head branch was pushed to by a user without write access
|
Just fixed the CI error, please take a look again when you have time, thanks @marioprats |
Description
Path::getPathSegment()currently scans from the beginning for every lookup. During time parameterization, queries usually move forward, so the same segments are visited repeatedly.This change stores the last segment index and resumes forward queries from there. Backward queries restart at the beginning. The cached index is atomic so concurrent const queries remain safe.
Results
Mean time for a full time-parameterization pass:
Testing
Added coverage for forward and backward queries, segment boundaries, copied paths, and concurrent queries.
Built
moveit_coreand ran the targeted test inmoveit/moveit2:humble-ci: 18/18 gtests passed; colcon reported 19 tests, 0 errors, 0 failures, 0 skipped.Checklist
Summary by CodeRabbit