Module 4 - Autonomy & Paths
Objective: execute reliable autonomous routines.
Prereqs: Command-based project and drive subsystem.
Steps
- Build autos with command sequences/command groups.
- Generate trajectories in PathPlanner; export and load in code.
- Test in simulation; validate odometry and event markers.
- Use alliance color for mirroring when needed; confirm starting pose and heading.
- Add fallbacks for odometry loss; timeouts on critical steps.
Deliverables
- Multi-step autonomous routine tested in sim (and on bot when available).
- Auto checklist: starting pose, gyro zero, path files loaded, button mapping.
Code example (simple auto command group)
Command auto = new SequentialCommandGroup(
new DriveDistance(drive, 2.0, 0.5),
new TurnToAngle(drive, 180),
new DriveDistance(drive, 1.0, 0.4)
);
Resources
- PathPlanner: pathplanner.dev
- Trajectory examples: docs.wpilib.org/en/stable/docs/software/pathplanning/index.html
Instructions (numbered)
- Define autonomous goals; plan steps and command sequence/command groups.
- Build trajectories in PathPlanner; export and load; set starting pose/heading.
- Implement auto selector and button mapping; add timeouts/fallbacks.
- Test in Sim GUI; validate odometry and event markers; mirror for alliance if needed.
- Test on-bot when available; log results and adjust.
Example
- Auto: drive 2 m, turn 180, drive 1 m; PathPlanner paths loaded, gyro zeroed at start, button B selects path.
Best practices
- Include a "safe" auto for reliability.
- Use timeouts and odometry fallbacks; log auto runs.
- Confirm paths updated on deploy; version control path files.
Common mistakes
- Wrong starting pose/heading; forgetting gyro zero.
- Missing alliance mirroring; stale path files.
- No timeouts — stuck commands.
Spec notes / data to log
- Paths: start pose/heading, alliance mirroring, constraints.
- Autos: timeouts, events markers, button/selector mapping.
- Data: log odometry, target states, and errors per auto run.
Checklist
- Paths built/exported and committed
- Starting pose/gyro set
- Auto selector/button set
- Timeouts/fallbacks added
- Sim test passed
- On-bot test logged
Recommended tools
- PathPlanner, Sim GUI, logging, field coordinate reference.
Sample log (template)
- Date:
- Auto tested:
- Results (sim/bot):
- Issues/fixes:
- Next changes:
Photos/diagrams
- [Placeholder: path diagram from PathPlanner]
Numeric Example
Example drivetrain path constraints:
- Max velocity: 3.0 m/s
- Max acceleration: 2.5 m/s²
- Max angular velocity: 6.0 rad/s
- Max angular acceleration: 8.0 rad/s²
Sample waypoint path:
- Start: (x = 0.0 m, y = 0.0 m, heading = 0°)
- Waypoint 1: (x = 1.5 m, y = 0.3 m, heading = 15°)
- Waypoint 2: (x = 3.0 m, y = 0.0 m, heading = 0°)
- End: (x = 4.5 m, y = -0.2 m, heading = -10°)
Expected autonomy behavior:
- Pose error at end of path: < 0.10 m, < 3°
- No wheel slip (no sudden spikes in accel beyond limits)
Data to Log
For autonomous path tests, log:
- Timestamp
- Desired pose (x, y, heading)
- Measured pose (x, y, heading)
- Path progress (0–100%)
- Wheel speeds
- Controller outputs
- Error in x, y, and heading
- Any events (brake mode, stop conditions, failsafes)