Skip to content

Commit

Permalink
fixed exception in auto routines example
Browse files Browse the repository at this point in the history
  • Loading branch information
oh-yes-0-fps committed Dec 6, 2024
1 parent b997828 commit 82cd315
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/choreolib/auto-routines.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ public AutoRoutine fivePieceAutoCompositionSeg(AutoFactory factory) {
// value
// AMP, SUB, SRC: The 3 starting positions
// Try to load all the trajectories we need
final AutoTrajectory ampToC1 = factory.voidRoutine().trajectory("ampToC1");
final Trajectory<SwerveSample> rawAmpToC1 = factory.cache().loadTrajectory("ampToC1");
final Command ampToC1 = factory.trajectoryCommand(rawAmpToC1);
final Command c1ToM1 = factory.trajectoryCommand("c1ToM1");
final Command m1ToS1 = factory.trajectoryCommand("m1ToS1");
final Command m1ToM2 = factory.trajectoryCommand("m1ToM2");
Expand All @@ -222,14 +223,17 @@ public AutoRoutine fivePieceAutoCompositionSeg(AutoFactory factory) {
final Command c2ToC3 = factory.trajectoryCommand("c2ToC3");
final Alert noStartingPoseErr = new Alert("Error: 5 piece auto has no starting pose", AlertType.kError);

AtomicBoolean hasInitialPose = new AtomicBoolean(true);

Command ret = sequence(
resetOdometry(() -> {
final Optional<Pose2d> initialPose = ampToC1.getInitialPose();
final Optional<Pose2d> initialPose = rawAmpToC1.getInitialPose();
if (initialPose.isPresent()) return initialPose.get();
noStartingPoseErr.set(true);
routine.kill();
hasInitialPose.set(false);
return new Pose2d();
}),
waitUntil(hasInitialPose::get),
autoAimAndShoot(),
deadline(
ampToC1.cmd(), intake(), aimFor(()->ampToC1.getFinalPose().orElseGet(Pose2d::new))),
Expand Down

0 comments on commit 82cd315

Please sign in to comment.