What autonomous needs
The first 15 to 20 seconds of an FRC match are autonomous: the robot runs with no driver input. (The exact length is set each season by the game manual — REEFSCAPE (2025) used 15 seconds; REBUILT (2026) uses 20 — so always confirm against the current year's manual.) A good auto combines driving (trajectories) with mechanism actions (intake, score) and finishes reliably. In command-based code, an entire auto is just one big composed command.
Returning the auto command
In the command-based template, Robot.autonomousInit() schedules whatever RobotContainer.getAutonomousCommand() returns:
public Command getAutonomousCommand() {
return Commands.sequence(
drivetrain.followPath("ToReef"), // a trajectory
arm.raiseToScore(), // mechanism action
intake.eject().withTimeout(1.0), // score
drivetrain.followPath("BackToStart"));
}
Sequences run steps in order; parallel groups let you, say, raise the arm while driving to save time:
Commands.deadline(
drivetrain.followPath("ToReef"), // deadline: ends when the drive ends
arm.raiseToScore()); // runs alongside
Letting drivers pick the auto
Matches need different autos depending on alliance strategy and starting position. Use a SendableChooser to expose options on the dashboard (Elastic, Glass, or Shuffleboard):
private final SendableChooser<Command> m_chooser = new SendableChooser<>();
public RobotContainer() {
m_chooser.setDefaultOption("Score + Leave", scoreAndLeaveAuto());
m_chooser.addOption("Just Leave", justLeaveAuto());
SmartDashboard.putData("Auto", m_chooser);
}
public Command getAutonomousCommand() { return m_chooser.getSelected(); }
If you're using PathPlanner, AutoBuilder.buildAutoChooser() can populate a chooser with every auto you built in the GUI automatically. With ChoreoLib, prefer its AutoChooser.
Reliability beats ambition
A few hard-won principles:
- Add timeouts. Wrap risky commands with
.withTimeout(...)so a stuck mechanism can't hang the whole auto. - Set the starting pose. Reset odometry to the path's start pose in the auto's first step, or your trajectory follower starts from a wrong belief about position. (PathPlanner/Choreo helpers can do this for you.)
- Test the exact starting position you'll use on the field; a few centimeters of offset compounds over a path.
- Prefer a simple auto that always works over a complex one that sometimes fails. A reliable "score one and leave" outscores an ambitious auto that no-shows half the time.
Putting it together
A complete auto module typically: resets odometry → follows a path (optionally doing mechanism work in parallel) → scores → repositions. Wired to a chooser and tested in simulation (next lesson) and on the practice field, this is what separates teams that reliably bank autonomous points from those that gamble on them.
Key takeaways
- Autonomous is one composed command returned from getAutonomousCommand().
- Use sequences for ordered steps and parallel/deadline groups to save time.
- Expose multiple autos with SendableChooser (or PathPlanner/Choreo choosers) on the dashboard.
- Reset odometry to the path's start pose and add timeouts to risky commands.
- A simple, reliable auto beats a complex one that fails — and always test the exact start position.
Lesson quiz
RequiredAnswer all 3 questions correctly to complete this lesson.
01.In WPILib's command-based framework, which command group runs its commands one after another in order?
02.What is the standard WPILib tool for letting drivers pick which autonomous routine runs from the dashboard?
03.A ParallelDeadlineGroup ends when which condition is met?
Answer every question to submit.
All 51 lessons in Programming, Controls & Sensors
- Not started:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not started:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not started:Mini-Project: A Teleop Swerve Drive Subsystem
- Not started:Mini-Project: An Autonomous Routine with PathPlanner
- Not started:Mini-Project: Vision-Aligned Scoring with Limelight
- Not started:State-Space Control and Kalman Filtering
- Not started:Log Replay Architecture with AdvantageKit
- Not started:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not started:Robot Coordination, Alerts, and Operator Feedback
- Not started:Case Study: Hardening Software Before an Event