Skip to content

feat: add distance-based path follower; fix interpolate bugs#2

Closed
JosephTLockwood wants to merge 1 commit into
feat/sample-by-distancefrom
feat/follow-path-distance-command
Closed

feat: add distance-based path follower; fix interpolate bugs#2
JosephTLockwood wants to merge 1 commit into
feat/sample-by-distancefrom
feat/follow-path-distance-command

Conversation

@JosephTLockwood

Copy link
Copy Markdown
Owner

Summary

Second of three PRs adding distance-based path following. Stacks on top of feat/sample-by-distance (PR #1, mjansen4857#1169 upstream).

Follower stack

  • FollowPathDistanceCommand -- drives by projected arc length instead of elapsed time. Closest-point-on-polyline projection over a lookahead window of state segments, with three guardrails: forward-saturation extension, big-gap fallback to full scan, and max-delta-per-tick clamp.
  • FollowPathDistanceCommand.EndConditions -- nested record holding distance/velocity/rotation tolerances with a defaults() factory (5cm / 0.1 m/s / 5 deg).
  • PPCrossTrackHolonomicController -- cross-track PD on perpendicular-to-tangent error (1D), heading PID, and optional curvature feedforward (kappa * v^2) to anticipate centripetal drift on curves.
  • PathPlannerTrajectoryState.curvatureRadPerMeter -- signed path curvature, populated automatically and preserved through interpolate/flip/reverse/copyWithTime.

Pre-existing bug fixes in PathPlannerTrajectoryState.interpolate

Three Euler-integration bugs surfaced by PR #1's sampleByDistance:

  1. Integration loop started at timeSeconds + 0.01, skipping the first 10 ms step. Every sample was under-integrated by one step (1cm at 1 m/s).
  2. For deltaT < 0.01, the break case computed a negative dt, producing backward integration near zero-velocity sections.
  3. For deltaT == 0, intT divided by zero, poisoning the pose with NaN.

Integration now starts at timeSeconds, uses remainingTime to gate the final partial step, and skips entirely when deltaT == 0. The heading is intentionally left unlerped (chord direction is constant within a segment).

Test plan

  • 23 new feature tests (controller, command, curvature)
  • 5 new interpolate regression tests
  • Existing PP test suite passes (43 tests total)
  • spotlessJavaCheck clean

Follower stack:
- FollowPathDistanceCommand: drives by projected arc length instead of
  elapsed time. Projects pose onto path via closest-point-on-polyline
  in a lookahead window, with three guardrails: forward-saturation
  extension, big-gap fallback to full scan, and max-delta-per-tick.
- FollowPathDistanceCommand.EndConditions: nested record holding
  distance, velocity, and rotation tolerances with defaults() factory.
- PPCrossTrackHolonomicController: cross-track PD on perpendicular-to-
  tangent error (1D), heading PID, and optional curvature feedforward
  (kappa * v^2) to anticipate centripetal drift on curves.
- PathPlannerTrajectoryState.curvatureRadPerMeter: signed path
  curvature, populated automatically and preserved through
  interpolate/flip/reverse/copy.

PathPlannerTrajectoryState.interpolate fixes (3 pre-existing bugs
surfaced by sampleByDistance):
- Integration loop started at timeSeconds + 0.01, skipping the first
  10 ms step (under-integration on every sample).
- For deltaT < 0.01, the break case computed a negative dt, producing
  backward motion near zero-velocity sections.
- For deltaT == 0, intT divided by zero, poisoning the pose with NaN.

Integration now starts at timeSeconds, uses remainingTime to gate the
final partial step, and skips entirely when deltaT == 0. The heading
(chord direction) is intentionally left unlerped during integration --
keeping integrated position on the segment chord and giving callers
the correct tangent for perpendicular cross-track measurement. 5 new
regression tests; existing tests pass unchanged.

23 new feature tests + 5 regression tests; total 43 tests pass.
@JosephTLockwood

Copy link
Copy Markdown
Owner Author

Re-targeting upstream against mjansen4857/pathplanner. See replacement PR there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant