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.
the part worth keeping
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.
Programming, Controls & SensorsAutonomous: Odometry, Trajectories, and Simulationlesson 3 of 4
Keep going
Take the quiz+10 XP with an accountMore in Autonomous: Odometry, Trajectories, and Simulation
where this came from
Sources and 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, in public, in the corrections log.
sources and further reading
- docs.wpilib.orgOrganizing Command-Based Robot Projects
- pathplanner.devPathPlanner: Build an Auto
- choreo.autosChoreoLib AutoFactory
clipped to this lesson
Articles that go further on this
The lesson gets you through the topic. These go wider on it, and they read in one sitting.
- 8 min readFRC Autonomous with PathPlanner: A Beginner's Guide to Auto RoutinesLearn how FRC teams build autonomous routines with PathPlanner (PPLib): paths vs autos, AutoBuilder, named commands, odometry, tuning, and Choreo./blogread it
- 12 min readChoreo vs PathPlanner: Planning FRC Autonomous TrajectoriesCompare Choreo and PathPlanner for FRC autonomous trajectories: how Choreo's time-optimal solver differs from PathPlanner's GUI paths, and when to use each./blogread it
- 9 min readFRC Command-Based Programming: Subsystems, Commands, and the SchedulerA beginner-friendly guide to WPILib command-based programming in Java: subsystems, commands, the CommandScheduler, triggers, and composing commands./blogread it
answer sheet
Lesson quiz
All 3 right completes the lesson. Miss one and only that question comes back, anything you already answered correctly stays banked.
0 of 3 answered
01In WPILib's command-based framework, which command group runs its commands one after another in order?
02What is the standard WPILib tool for letting drivers pick which autonomous routine runs from the dashboard?
03A ParallelDeadlineGroup ends when which condition is met?
Answer every question to submit.
All 51 lessons in Programming, Controls & Sensorsopenclose
01 / prerequisites
02 / foundations-tools-and-first-program
03 / robot-program-and-command-based
04 / motors-and-control
05 / autonomous-trajectories-simulation
06 / sensing-fundamentals
07 / encoders
08 / gyros-imus-orientation
09 / closed-loop-control
10 / vision-pose-estimation
11 / worked-examples-mini-projects
- Not read yet:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not read yet:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not read yet:Mini-Project: A Teleop Swerve Drive Subsystem
- Not read yet:Mini-Project: An Autonomous Routine with PathPlanner
- Not read yet:Mini-Project: Vision-Aligned Scoring with Limelight
12 / common-mistakes-troubleshooting
13 / advanced-techniques-case-studies
- Not read yet:State-Space Control and Kalman Filtering
- Not read yet:Log Replay Architecture with AdvantageKit
- Not read yet:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not read yet:Robot Coordination, Alerts, and Operator Feedback
- Not read yet:Case Study: Hardening Software Before an Event