[wpilib] Fix DiffDriveSim pose reset and example (#2837)

Calling the resetPosition method on an odometry instance expects encoder positions to be reset to zero.
This commit is contained in:
Prateek Machiraju
2020-11-12 01:37:14 -05:00
committed by GitHub
parent 5c2dc043cd
commit 616405f7ae
4 changed files with 8 additions and 0 deletions

View File

@@ -130,6 +130,9 @@ public class RobotContainer {
m_robotDrive
);
// Reset odometry to starting pose of trajectory.
m_robotDrive.resetOdometry(exampleTrajectory.getInitialPose());
// Run path following command, then stop at the end.
return ramseteCommand.andThen(() -> m_robotDrive.tankDriveVolts(0, 0));
}

View File

@@ -163,6 +163,7 @@ public class DriveSubsystem extends SubsystemBase {
*/
public void resetOdometry(Pose2d pose) {
resetEncoders();
m_drivetrainSimulator.setPose(pose);
m_odometry.resetPosition(pose, Rotation2d.fromDegrees(getHeading()));
}