Skip to content

Commit

Permalink
Fix differential drive trajectories
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansen4857 committed Mar 9, 2025
1 parent 148181f commit 91783e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pathplannerlib-python/pathplannerlib/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ def _generateStates(states: List[PathPlannerTrajectoryState], path: PathPlannerP
else:
state.heading = states[i - 1].heading

if not config.isHolonomic:
state.pose = Pose2d(state.pose.translation(), state.heading)

if i != 0:
state.deltaPos = state.pose.translation().distance(states[i - 1].pose.translation())
state.deltaRot = state.pose.rotation() - states[i - 1].pose.rotation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ private static void generateStates(
state.heading = states.get(i - 1).heading;
}

if (!config.isHolonomic) {
state.pose = new Pose2d(state.pose.getTranslation(), state.heading);
}

if (i != 0) {
state.deltaPos =
state.pose.getTranslation().getDistance(states.get(i - 1).pose.getTranslation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ void PathPlannerTrajectory::generateStates(
state.heading = states[i - 1].heading;
}

if (!config.isHolonomic) {
state.pose = frc::Pose2d(state.pose.Translation(), state.heading);
}

if (i != 0) {
state.deltaPos = state.pose.Translation().Distance(
states[i - 1].pose.Translation());
Expand Down

0 comments on commit 91783e3

Please sign in to comment.