Safe Auto Failover
Disclaimer: WIP and untested; validate paths and timings on your robot. Custom code built on WPILib APIs.
Plan: Provide a low-risk auto: taxi, stash/preload fuel safely, no shooting unless hub state confirmed.
Code (Java, chooser hook)
public Command safeAuto(DriveSubsystem drive) {
PathPlannerTrajectory traj = PathPlanner.loadPath("Taxi",
new PathConstraints(2.0, 2.0));
return new SequentialCommandGroup(
new InstantCommand(() -> drive.resetOdometry(traj.getInitialHolonomicPose())),
AutoBuilder.followPath(traj)
);
}
public Command getSelected(boolean hubDataAvailable) {
AutoMode mode = chooser.getSelected();
if (mode == null) mode = AutoMode.FUEL_L1;
if (!hubDataAvailable && mode == AutoMode.FUEL_L1) mode = AutoMode.SAFE;
return switch (mode) {
case FUEL_L1 -> fuelL1;
case FUEL_ONLY -> fuelOnly;
case TAXI_ONLY, SAFE -> safeAuto;
};
}
Checklist
- Safe path defined (short taxi, no risky turns).
- Hub/vision check sets fallback to SAFE when bad/missing.
- Manual button to force SAFE selection on DS.