feat: add distance-based sampling to PathPlannerTrajectory#1169
Open
JosephTLockwood wants to merge 1 commit into
Open
feat: add distance-based sampling to PathPlannerTrajectory#1169JosephTLockwood wants to merge 1 commit into
JosephTLockwood wants to merge 1 commit into
Conversation
Adds: - PathPlannerTrajectoryState.distanceAlongPath: cumulative arc length from the trajectory start, populated automatically in both constructors and preserved through interpolate/flip/reverse/copy. - PathPlannerTrajectory.sampleByDistance(double): query the trajectory by arc length instead of elapsed time. Useful for projection-based path following where progress is tracked from odometry rather than a timer. - PathPlannerTrajectory.getTotalArcLength(): total chord-summed length. Purely additive -- no existing behavior changes. 11 new unit tests cover population, monotonicity, clamping, interpolation, agreement with sample(time), and preservation through flip/copy.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1169 +/- ##
==========================================
- Coverage 84.59% 84.58% -0.02%
==========================================
Files 95 95
Lines 9750 9750
==========================================
- Hits 8248 8247 -1
- Misses 1502 1503 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced May 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a way to query
PathPlannerTrajectoryby arc length instead of elapsed time. Purely additive -- no existing behavior changes.PathPlannerTrajectoryState.distanceAlongPath-- cumulative arc length from trajectory start. Populated in both constructors; preserved throughinterpolate,flip,reverse,copyWithTime.PathPlannerTrajectory.sampleByDistance(double)-- binary search ondistanceAlongPath, then lerp via existinginterpolate. Mirrorssample(double time)'s structure.PathPlannerTrajectory.getTotalArcLength()-- chord-summed total.Why
Projection-based path followers track progress from odometry rather than a timer. This lets the follower query "where should I be at arc length s?" without converting s->t. Useful when the robot is held up (obstacle, disturbance) and a time-based reference would race ahead, or when cross-track error is measured perpendicular to tangent at the robot's actual progress.
Test plan
PathPlannerTrajectoryTest.java(population, monotonicity, clamping, interpolation, agreement withsample(time)on straight + arc, preservation through flip/copy)spotlessJavaCheckclean