Offseason · Week 6 of 8
Autonomous & PathPlanner
Auto sequences, field coordinates, odometry, and PathPlanner.
Autonomous Period
During the 15-second auto period, the robot runs entirely on its own — no driver input. Your code must handle all movement, scoring, and positioning decisions using sensors and pre-planned paths.
java — simple auto command sequence
import static edu.wpi.first.wpilibj2.command.Commands.*; Command getAutoCommand() { return sequence( new DriveForwardCommand(drive, 1.5), // drive 1.5m parallel( new SpinUpShooterCommand(shooter), // spin up while new WaitCommand(1.5) // waiting 1.5s ), new ScoreCommand(shooter), // shoot new DriveBackCommand(drive, 0.5) // back off ); }
PathPlanner
PathPlanner is a tool for designing robot paths visually and following them precisely using odometry. Most competitive teams use it for complex multi-note or multi-piece autos.
java — PathPlanner auto
import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.path.PathPlannerPath; // Load a path created in PathPlanner app PathPlannerPath path = PathPlannerPath.fromPathFile("2 Piece Auto"); // Follow it Command autoCmd = AutoBuilder.followPath(path); // Or build a named auto from PathPlanner Command namedAuto = AutoBuilder.buildAuto("2 Piece Center");
Auto Chooser
java — RobotContainer auto chooser
private final SendableChooser<Command> autoChooser = new SendableChooser<>(); public RobotContainer() { autoChooser.setDefaultOption("Do Nothing", new WaitCommand(15)); autoChooser.addOption("Drive Forward", new DriveForwardCommand(drive, 1.5)); autoChooser.addOption("2 Piece", AutoBuilder.buildAuto("2 Piece Center")); SmartDashboard.putData("Auto Mode", autoChooser); } public Command getAutonomousCommand() { return autoChooser.getSelected(); }