Lesson 4.12: Reading Autonomous Routines
π― What Youβll Learn
By the end of this lesson you will be able to:
- Explain how PathPlanner organizes autonomous routines into paths and autos
- Read a PathPlanner JSON path file and identify waypoints, constraints, and rotation targets
- Identify Named Commands in your teamβs code and explain how they connect to PathPlanner events
- Describe how the auto chooser selects and runs an autonomous routine
- Navigate the PathPlanner documentation at pathplanner.dev
What Is PathPlanner?
PathPlanner is the tool most FRC teams use to create autonomous routines. Instead of writing code that says βdrive forward 2 meters, turn left 90 degrees,β you draw paths on a field map and PathPlanner generates the math to follow them smoothly.
PathPlanner has two parts:
- The GUI β a desktop application where you draw paths on a field image
- The library β a Java/C++/Python library that your robot code uses to follow those paths
Your teamβs PathPlanner files live in the src/main/deploy/pathplanner/ directory. Letβs explore whatβs in there.
Paths vs. Autos
PathPlanner organizes autonomous routines into two types of files:
| Type | Location | What It Contains |
|---|---|---|
| Path | deploy/pathplanner/paths/ | A single trajectory β a series of waypoints the robot drives through |
| Auto | deploy/pathplanner/autos/ | A complete routine β a sequence of paths and commands that runs during autonomous |
Think of it like a road trip:
- A path is a single road segment (e.g., βdrive from the starting zone to the first game pieceβ)
- An auto is the complete trip itinerary (e.g., βdrive to piece 1, pick it up, drive to the scoring zone, score, drive to piece 2β¦β)
The File Structure
src/main/deploy/pathplanner/βββ paths/β βββ StartToNote1.path β JSON file defining a single trajectoryβ βββ Note1ToScore.path β Another trajectoryβ βββ ScoreToNote2.path β And anotherβ βββ ...βββ autos/β βββ TwoNoteAuto.auto β Combines paths + commands into a routineβ βββ ThreeNoteAuto.auto β Another complete routineβ βββ ...βββ settings.json β Robot dimensions, max speed, etc.Reading a Path File
Path files are JSON β structured text that describes waypoints, constraints, and rotation targets. Letβs read one.
Open any .path file in your teamβs deploy/pathplanner/paths/ directory. Youβll see something like:
{ "version": "2025.0", "waypoints": [ { "anchor": { "x": 1.35, "y": 5.55 }, "prevControl": null, "nextControl": { "x": 2.0, "y": 5.55 } }, { "anchor": { "x": 2.85, "y": 5.55 }, "prevControl": { "x": 2.2, "y": 5.55 }, "nextControl": null } ], "rotationTargets": [ { "waypointRelativePos": 0.5, "rotationDegrees": 0.0 } ], "constraintZones": [], "globalConstraints": { "maxVelocity": 3.0, "maxAcceleration": 2.5, "maxAngularVelocity": 540.0, "maxAngularAcceleration": 720.0 }}Breaking Down the JSON
| Field | What It Means |
|---|---|
waypoints | The points the robot drives through. Each has an anchor (the point itself) and control points (that shape the curve) |
anchor | The x, y position on the field in meters. (0,0) is the bottom-left corner of the field |
prevControl / nextControl | Bezier curve control points β they determine how the robot curves into and out of each waypoint |
rotationTargets | Where the robot should be facing at specific points along the path |
globalConstraints | Speed limits β max velocity (m/s), max acceleration (m/sΒ²), and angular limits (deg/s) |
constraintZones | Sections of the path with different speed limits (e.g., slow down near a scoring position) |
You donβt need to memorize the JSON format β the PathPlanner GUI handles creating and editing these files. But being able to read them helps you understand what the robot will do and debug issues.
In a PathPlanner path file, what do the 'globalConstraints' control?
Reading an Auto File
Auto files combine paths and commands into a complete autonomous routine. Open any .auto file:
{ "version": "2025.0", "startingPose": { "position": { "x": 1.35, "y": 5.55 }, "rotation": 0.0 }, "command": { "type": "sequential", "data": { "commands": [ { "type": "named", "data": { "name": "StartIntake" } }, { "type": "path", "data": { "pathName": "StartToNote1" } }, { "type": "named", "data": { "name": "StopIntake" } }, { "type": "path", "data": { "pathName": "Note1ToScore" } }, { "type": "named", "data": { "name": "ShootNote" } } ] } }}Breaking Down the Auto
| Field | What It Means |
|---|---|
startingPose | Where the robot starts on the field (position + heading) |
command | The sequence of actions to perform |
type: "sequential" | Run commands one after another (like SequentialCommandGroup) |
type: "path" | Follow a PathPlanner path |
type: "named" | Run a Named Command registered in your Java code |
Reading this auto: the robot starts the intake, drives to Note 1, stops the intake, drives to the scoring position, and shoots. Each step happens in order.
Named Commands β The Bridge Between PathPlanner and Java
Named Commands are the connection point between PathPlannerβs auto files and your Java code. When PathPlanner sees "type": "named", "data": { "name": "StartIntake" }, it looks up a command registered with that name in your Java code.
Where Named Commands Are Registered
Search your project for NamedCommands.registerCommand β youβll find registrations in RobotContainer or a dedicated auto configuration method:
// Register commands that PathPlanner autos can reference by nameNamedCommands.registerCommand("StartIntake", new InstantCommand(() -> intakeSubsystem.deployOut(), intakeSubsystem) .andThen(new RunCommand(() -> intakeSubsystem.runIntake(0.5), intakeSubsystem)));
NamedCommands.registerCommand("StopIntake", new InstantCommand(() -> { intakeSubsystem.stopIntake(); intakeSubsystem.deployIn(); }));
NamedCommands.registerCommand("ShootNote", new AutoShootCommand(shooterSubsystem, turretSubsystem));The string name ("StartIntake", "StopIntake", "ShootNote") must match exactly whatβs in the .auto file. If thereβs a typo, PathPlanner wonβt find the command and that step will be skipped silently.
The Complete Flow
PathPlanner GUI .auto JSON file Java Codeβββββββββββββββ ββββββββββββββββ ββββββββββDraw paths β "pathName": "StartToNote1" β PathPlanner library follows pathAdd named command β "name": "StartIntake" β NamedCommands.registerCommand("StartIntake", ...)Set starting pose β "startingPose": {...} β Robot resets odometry to this positionThe Auto Chooser Connection
Remember the autonomous chooser from Lesson 4.9? PathPlanner integrates with it. Most teams use PathPlannerβs AutoBuilder to automatically create the chooser:
// AutoBuilder reads all .auto files and creates a chooserautoChooser = AutoBuilder.buildAutoChooser();SmartDashboard.putData("Auto Chooser", autoChooser);This scans the deploy/pathplanner/autos/ directory, creates a command for each .auto file, and adds them to a SendableChooser. The drive team selects which auto to run from the dashboard before the match.
-
Path vs Auto: A
.pathfile defines a single trajectory (waypoints, constraints, rotation targets). An.autofile defines a complete autonomous routine that combines multiple paths and Named Commands in a sequence. -
Named Commands connection: In Java, you call
NamedCommands.registerCommand("name", command)to register a command with a string name. In the.autofile,"type": "named", "data": { "name": "name" }references that registered command. PathPlanner looks up the name at runtime and runs the corresponding Java command. -
Name mismatch: If the name doesnβt match, PathPlanner wonβt find the command and that step will be skipped silently β no error, no crash, just a missing action. This is a common bug source. Always double-check that names match exactly (case-sensitive).
Navigating PathPlanner Documentation
The PathPlanner documentation at pathplanner.dev is your reference for everything auto-related. Key sections:
| Section | What Youβll Find |
|---|---|
| Getting Started | Installation, project setup, basic path creation |
| GUI Overview | How to use the PathPlanner desktop application |
| Path Following | How the robot follows paths (PID tuning, feedforward) |
| Named Commands | How to register and use Named Commands |
| Auto Builder | How AutoBuilder creates the auto chooser |
| Event Markers | How to trigger commands at specific points along a path |
For now, focus on understanding the structure. In Unit 5 (Lesson 5.13), youβll learn to create paths and autos. In Unit 6 (Lesson 6.16), youβll explore advanced features like on-the-fly path generation.
Key Terms
π All terms below are also in the full glossary for quick reference.
| Term | Definition |
|---|---|
| PathPlanner | An FRC tool for creating autonomous paths and routines, consisting of a GUI for drawing paths and a library for following them |
| Path | A single trajectory defined by waypoints, constraints, and rotation targets, stored as a .path JSON file |
| Auto | A complete autonomous routine combining paths and Named Commands in a sequence, stored as an .auto JSON file |
| Named Command | A command registered with a string name in Java code, referenced by PathPlanner autos to trigger robot actions during path following |
| Waypoint | A point on the field that the robot drives through, with control points that shape the curve of the trajectory |
| AutoBuilder | A PathPlanner utility that automatically creates an auto chooser from all .auto files in the deploy directory |
Whatβs Next?
You can now read PathPlanner files and understand how autonomous routines are structured β from JSON waypoints to Named Commands to the auto chooser. This is the foundation for working with autonomous code.
In Activity 4.13: Read an Auto Routine, youβll open the PathPlanner GUI, load your teamβs project, and visually trace an existing auto routine from start to finish β seeing the paths on the field and connecting them to the Named Commands in your Java code.
In Activity 4.13: Read an Auto Routine, youβll open the PathPlanner GUI, load your teamβs project, and visually trace an existing auto routine from start to finish β seeing the paths on the field and connecting them to the Named Commands in your Java code.