What autonomous needs
The first ~15 seconds of an FRC match are autonomous: the robot runs with no driver input. 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.
Keep going
Take the quiz · +10 XP with an accountMore in Autonomous: Odometry, Trajectories, and Simulation
Sources & corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed — publicly, in the corrections log.
Sources and further reading
- Organizing Command-Based Robot Projectsdocs.wpilib.org
- PathPlanner: Build an Autopathplanner.dev
- ChoreoLib AutoFactorychoreo.autos
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
- 8 min read
FRC Autonomous with PathPlanner: A Beginner's Guide to Auto Routines
Learn how FRC teams build autonomous routines with PathPlanner (PPLib): paths vs autos, AutoBuilder, named commands, odometry, tuning, and Choreo.
Read - 12 min read
Choreo vs PathPlanner: Planning FRC Autonomous Trajectories
Compare Choreo and PathPlanner for FRC autonomous trajectories: how Choreo's time-optimal solver differs from PathPlanner's GUI paths, and when to use each.
Read - 9 min read
FRC Command-Based Programming: Subsystems, Commands, and the Scheduler
A beginner-friendly guide to WPILib command-based programming in Java: subsystems, commands, the CommandScheduler, triggers, and composing commands.
Read
Lesson quiz
RequiredAll 3 right completes the lesson. Miss one and only that question comes back — anything you already answered correctly stays banked.
0 of 3 answered
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