Activity 5.14: Build an Auto Routine
🎯 Goal
By the end of this activity you will have:
- Created a new path in PathPlanner with at least 3 waypoints
- Registered a new Named Command in your team’s RobotContainer
- Composed an auto routine that uses your path and Named Command
- Verified the auto routine appears in the auto chooser
Step 1: Create a Git Branch
Before making any changes, create a practice branch:
git checkout -b practice/build-autoStep 2: Create a New Path
- Open PathPlanner and click “New Path”
- Name it something descriptive (e.g.,
PracticeScoreToPickup) - Click on the field to place at least 3 waypoints:
- Waypoint 1: Starting position (near a scoring location)
- Waypoint 2: A midpoint (adjust the curve to avoid obstacles)
- Waypoint 3: Ending position (near a game piece location)
- Set rotation targets if you want the robot to face a specific direction at any point
- Set path constraints:
- Max velocity: 2.5 m/s (conservative for practice)
- Max acceleration: 2.0 m/s²
Document your path:
| Property | Value |
|---|---|
| Path name | |
| Number of waypoints | |
| Start position (x, y) | |
| End position (x, y) | |
| Max velocity | |
| Max acceleration | |
| Rotation targets? |
Step 3: Register a Named Command
Open
Choose one of these options:
Option A: Simple Print Command (Safe for Testing)
NamedCommands.registerCommand("PracticeAction", new InstantCommand(() -> System.out.println("Practice Named Command executed!")));Option B: Intake Command (If Robot Is Available)
NamedCommands.registerCommand("PracticeIntake", new SequentialCommandGroup( new InstantCommand(() -> intakeSubsystem.deployOut(), intakeSubsystem), new WaitCommand(0.3), new InstantCommand(() -> intakeSubsystem.stopDeploy()), new RunCommand(() -> intakeSubsystem.runIntake(0.3), intakeSubsystem) .withTimeout(2.0) ).finallyDo(() -> { intakeSubsystem.stopIntake(); intakeSubsystem.deployIn(); }));Important: Add the registration in the same area as existing NamedCommands.registerCommand() calls — before AutoBuilder is configured.
| Question | Your Answer |
|---|---|
| Named Command name | |
| What it does | |
| Where you added it in RobotContainer |
Step 4: Compose the Auto Routine
- In PathPlanner, click “New Auto”
- Name it (e.g.,
PracticeAuto) - Set the starting pose to match your path’s first waypoint
- Add actions in this order:
- Named Command: Your registered command name (e.g.,
"PracticeAction") - Follow Path: Your new path (e.g.,
PracticeScoreToPickup) - Named Command: Your registered command again (or a different one)
- Named Command: Your registered command name (e.g.,
- Save the auto
Document your auto structure:
| Step | Action Type | Name/Details |
|---|---|---|
| 1 | Starting Pose | (x, y, heading) |
| 2 | ||
| 3 | ||
| 4 |
Step 5: Build and Verify
- Save all files in your IDE
- Build the project to check for compile errors:
./gradlew build- If the build succeeds, check that your auto appears in the code. Look for where
AutoBuilder.buildAutoChooser()is called — your new auto should be automatically discovered from the PathPlanner files.
Common issues when adding Named Commands:
- Import missing: Add
import com.pathplanner.lib.auto.NamedCommands;at the top of RobotContainer - Command reference error: Make sure the subsystem variable exists and is initialized before the Named Command registration
- Name mismatch: The string name in
registerCommand()must exactly match what you typed in PathPlanner - Registration order: Named Commands must be registered before
AutoBuilderis configured
Step 6: Test on the Robot (If Available)
If you have access to the robot:
- Deploy the code:
./gradlew deploy - Open the Driver Station
- Check the auto chooser dropdown — your new auto should appear
- Select your auto
- Place the robot at the starting position
- Enable autonomous mode
- Watch the robot execute your auto
If the robot isn’t available, verify these things instead:
- The build succeeds without errors
- The Named Command registration is in the right place
- The PathPlanner auto file exists in
src/main/deploy/pathplanner/autos/ - The path file exists in
src/main/deploy/pathplanner/paths/
Step 7: Iterate
If the auto didn’t work perfectly (it rarely does on the first try), iterate:
- Path issues — Adjust waypoints in PathPlanner if the robot’s trajectory is off
- Timing issues — Add or adjust
Waitcommands if actions happen too early or late - Named Command issues — Check DS console for errors; verify the command name matches
- Constraint issues — Lower max velocity if the robot overshoots waypoints
A complete answer includes:
-
Path description — “I created PracticeScoreToPickup with 3 waypoints: starting at (1.4, 5.5) near the speaker, curving around the stage, and ending at (8.0, 4.0) near the center game piece. Max velocity 2.5 m/s.”
-
Named Command — “I registered ‘PracticeAction’ as a print command for safe testing. Once verified, I’d replace it with an actual intake command.”
-
Build result — “Build succeeded after fixing a missing import for NamedCommands.”
-
Testing plan — “First thing I’d check: does the auto appear in the DS chooser? Then I’d run it at low speed to verify the path shape, and check the DS console for the print statement from my Named Command.”
Cleanup
When you’re done practicing, you can either:
- Keep your work: Merge the branch to main if the auto is useful
- Discard your work:
git checkout mainandgit branch -D practice/build-auto
Either way, you’ve practiced the complete auto creation workflow.
What’s Next?
You’ve built your first auto routine from scratch. In Activity 5.15: Compare Auto Routines, you’ll compare your team’s autonomous approach to a top team’s — examining how they structure their paths, Named Commands, and auto composition to score more game pieces in 15 seconds.