Skip to content

Commit fc8c870

Browse files
authored
Merge pull request #54 from DeepBlueRobotics/fix-heading-supplier
Create a `RobotPath.HeadingSupplier.stop()` Method
2 parents b690a1d + da9e353 commit fc8c870

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/main/java/org/carlmontrobotics/lib199/path/RobotPath.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ public Command getPathCommand(boolean faceInPathDirection, boolean stopAtEnd) {
8585
if (trajectory == null) {
8686
generateTrajectory();
8787
}
88-
hs.reset();
8988
// We want the robot to stay facing the same direction (in this case), so save
9089
// the current heading (make sure to update at the start of the command)
9190
AtomicReference<Rotation2d> headingRef = new AtomicReference<>(dt.getPose().getRotation());
9291
Supplier<Rotation2d> desiredHeading = (!faceInPathDirection) ? () -> headingRef.get() : () -> hs.sample();
9392
Command command = dt.createAutoCommand(trajectory, desiredHeading);
93+
command = new InstantCommand(hs::reset).andThen(command, new InstantCommand(hs::stop));
9494
if (stopAtEnd) {
9595
command = command.andThen(new InstantCommand(dt::stop, dt));
9696
}
@@ -310,5 +310,13 @@ public void reset() {
310310
timerStarted = false;
311311
timer.reset();
312312
}
313+
314+
/**
315+
* Stops the timer
316+
*/
317+
public void stop() {
318+
timer.stop();
319+
reset();
320+
}
313321
}
314322
}

0 commit comments

Comments
 (0)