Autonomous & Choreo
Auto sequences, field coordinates, odometry, and Choreo path following.
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.
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 ); }
Choreo Path Following
Choreo is WRT's path following library. you design robot trajectories visually in the Choreo desktop app, export them, and follow them precisely in code using odometry. it integrates tightly with WPILib's command-based architecture and is what you'll use for all multi-piece autos on the actual robot.
why Choreo, not PathPlanner? Choreo generates time-optimized trajectories with physics constraints baked in, exports a standard JSON format, and has first-class WPILib integration. it's also what the team has standardized on — so all existing auto routines use it. see the style guide for the team's official stance.
import choreo.auto.AutoFactory; import choreo.auto.AutoRoutine; import choreo.auto.AutoTrajectory; // In RobotContainer, build a routine from a .traj file AutoRoutine twopiece = autoFactory.newRoutine("twoPiece"); AutoTrajectory traj = twopiece.trajectory("twoPiece"); // chain commands: follow path, then score twopiece.active().onTrue( traj.cmd().andThen(new ScoreCommand(m_shooter)) ); return twopiece.cmd();
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(); }