Skip to content

Commit

Permalink
added reset() in PathDriveCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
jhhbrown1 committed Feb 14, 2025
1 parent eb7c83d commit 4524ffa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/CommandComposer.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ distanceTolerance, angleTolerance, pose(0.0, 0, 0)).withTimeout(1),
*
* @return a {@code Command} for moving the robot on a circle
*/
public static Command moveOnEllipse(double radius, double initialAngularIncrement, double finalAngularIncrement,
public static Command moveOnOval(double radius, double initialAngularIncrement, double finalAngularIncrement,
double distanceTolerance, double angleTolerance, double intermediateToleranceRatio, int poseCount) {
Rotation2d angle = Rotation2d.kZero;
var l = new LinkedList<Pose2d>();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public Robot() {
CommandComposer.moveForwardBackward2Controllers(6, distanceTolerance, angleToleranceInDegrees));
m_testSelector
.addOption(
"Check PID Constants for Driving (Ellipe with Max Radius of 1m)",
CommandComposer.moveOnEllipse(
"Check PID Constants for Driving (Oval with Max Radius of 1m)",
CommandComposer.moveOnOval(
1, 8, 16, distanceTolerance, angleToleranceInDegrees, 16, 360 / 12 * 3 / 2));
m_testSelector
.addOption(
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/commands/PathDriveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public PathDriveCommand(DriveSubsystem driveSubsystem,
*/
@Override
public void initialize() {
targetPoseSupplier().reset();
moveToNextTargetPose();
Pose2d pose = m_driveSubsystem.getPose();
m_controllerXY.reset(m_targetPose.minus(pose).getTranslation().getNorm());
Expand Down Expand Up @@ -169,6 +170,13 @@ public IterativeTargetPoseSupplier(List<Supplier<Pose2d>> targetPoseSuppliers) {
m_targetPoseSuppliers = targetPoseSuppliers;
}

/**
* Resets this {@code IterativeTargetPoseSupplier}.
*/
public void reset() {
m_targetPoseIndex = 0;
}

/**
* Returns the curent target {@code Pose2d}.
*
Expand Down

0 comments on commit 4524ffa

Please sign in to comment.