Learning Swerve From Scratch¶
Welcome! This site is the training course for our FRC team's swerve drive project.
We are building a swerve drive from scratch to learn how it works. This is a teaching project, not competition code. Once we understand the system, we will switch to an established library (YAGSL, or CTRE's swerve generator) for competition.
Note
Understanding matters more than speed. You will write the core math yourselves, then check it against WPILib.
How the course works¶
Each phase follows the same pattern:
- Theory first. Plain-language explanation, small worked examples, ASCII diagrams.
- Small steps. One concept at a time. Every step compiles, runs in simulation, and is testable.
- You write the core math (kinematics, optimization, odometry). Your mentor reviews and asks guiding questions.
- Hand-roll, then compare to WPILib with a unit test.
- Checkpoint: summary, quiz questions, and what can go wrong in the real world.
Roadmap¶
| Phase | Topic | You will be able to... |
|---|---|---|
| 0 | Setup | Build and run a command-based project in simulation |
| 1 | Geometry and frames | Predict the sign of every value in the robot frame |
| 2 | One swerve module | Make a simulated module track angle and speed |
| 3 | Module optimization | Never rotate a wheel more than 90° |
| 4 | Inverse kinematics | Hand-compute module states for any chassis motion |
| 5 | Four modules + teleop | Drive a simulated robot with a controller |
| 6 | Gyro, field-relative | Make "stick up" always mean away from the driver |
| 7 | Forward kinematics, odometry | Track where the robot is on the field |
| 8 | Discretization | Remove the "drifting in an arc" skew |
| 9 | Real hardware | Safely bring up real motors and encoders |
| 10 | Tuning | Characterize with SysId and tune gains |
| 11 | Autonomous basics | Drive to a pose automatically |
| 12 | Graduation | Map our code to YAGSL and debug it |
Starting a session¶
When you open a new work session, state which phase you are on. Recap what the previous phase covered (check the git log and the code), then continue from there.