Path/Auto Template
Disclaimer: WIP and untested on 2026 hardware; adapt to your path library and tune constraints. Custom code built on WPILib APIs (not official WPILib sample).
Purpose: Run a PathPlanner path with events for intake/shot, plus a taxi-only fallback.
Code (Java, PathPlanner)
Assumes you have PathPlanner set up with a path named “FuelL1”.
public class AutoFactory {
private final DriveSubsystem drive;
private final IntakeSubsystem intake;
private final ShooterSubsystem shooter;
private final IndexerSubsystem indexer;
public AutoFactory(DriveSubsystem drive, IntakeSubsystem intake, ShooterSubsystem shooter, IndexerSubsystem indexer) {
this.drive = drive;
this.intake = intake;
this.shooter = shooter;
this.indexer = indexer;
}
public Command fuelL1Auto() {
HashMap<String, Command> events = new HashMap<>();
events.put("INTAKE_ON", new InstantCommand(intake::in, intake));
events.put("INTAKE_OFF", new InstantCommand(intake::stop, intake));
events.put("SHOOT", new FireCommand(shooter, indexer, () -> HubShiftTimer.HubState.ACTIVE));
PathPlannerTrajectory traj = PathPlanner.loadPath("FuelL1",
new PathConstraints(3.0, 2.0));
return new SequentialCommandGroup(
new InstantCommand(() -> drive.resetOdometry(traj.getInitialHolonomicPose())),
AutoBuilder.followPathWithEvents(traj, events)
);
}
public Command taxiOnly() {
PathPlannerTrajectory traj = PathPlanner.loadPath("Taxi",
new PathConstraints(2.0, 2.0));
return new SequentialCommandGroup(
new InstantCommand(() -> drive.resetOdometry(traj.getInitialHolonomicPose())),
AutoBuilder.followPath(traj)
);
}
}
How to test
- Sim: run paths without robot; check odometry reset and event markers fire.
- Field: start pose aligned to initial pose; verify intake/shot events trigger in order.
- Provide a taxi-only path for venues where full auto is risky.
Pitfalls
- Ensure odometry reset matches starting pose on the carpet.
- Constrain speeds so you don’t slip; tune kinematics and feedforward first.