Swerve Drive
How a swerve drivetrain works. Its parts and what each one does, the kinematics math, module control, gearing and traction, and why it replaced tank and mecanum drives.
This section explains how a swerve drive works. Each of its four wheels sits in a module that both spins the wheel and turns it to point anywhere. Pointing all four wheels the right way lets the robot move in any direction, and turn at the same time or not at all. Its direction of travel and the way it faces are independent. A drivetrain that can do this is called holonomic (§1.1). Swerve is the drivetrain most competitive FRC teams use today.
The section starts with why teams moved to swerve from older drivetrains, then takes a module apart, works through the math that turns a joystick input into four wheel commands, and ends with how gearing and traction set the robot's speed. The team's on-carpet tuning procedure is a separate page: Swerve Tuning.
What you need
High-school algebra and a little trigonometry (sine, cosine, and the angle of a vector). Vectors and one matrix appear on the Kinematics page, and each step is explained. Two pages have an interactive widget.
Where to start
Read the pages in order. Each one builds on the one before.
1. Why Swerve
Tank, mecanum, and other drivetrains, what each does well, and what swerve gives you and costs you.
2. Anatomy of a Swerve Drive
The drive and steer motors, the absolute encoder, gearing, coupling, wheels, and the gyro, and what each one is for.
3. Swerve Kinematics
Turn a chassis velocity into four module speeds and angles. Field-relative driving, the center of rotation, and desaturation.
4. Commanding the Modules
Never turn more than 90°, slow a wheel that points the wrong way, and the full path from joystick to motor.
5. Speed, Acceleration, and Traction
How gear ratio, wheel size, weight, and current limits set top speed, acceleration, and the current at which wheels slip.
Key ideas at a glance
| Idea | One-line summary | Page |
|---|---|---|
| Holonomic | A swerve robot controls , , and heading separately. A tank robot has to turn to change direction. | Why Swerve |
| Full traction in every direction | Mecanum wheels also move sideways, but push through rollers. Swerve turns the whole tread to face the direction of travel. | Why Swerve |
| Absolute encoder | The steer motor's own encoder forgets where the wheel points at power-up. The absolute encoder doesn't. | Anatomy of a Swerve Drive |
| One formula per module | Each module moves with the robot's center plus the turn rate times its distance from the center, turned 90°. | Swerve Kinematics |
| Field-relative | Rotate the driver's request by the gyro heading, so "up the stick" is always "up the field". | Swerve Kinematics |
| Desaturate, don't clip | If one module is asked to go too fast, slow every module by the same factor so the robot keeps its direction. | Swerve Kinematics |
| Never turn more than 90° | Reverse the wheel and turn the short way instead. | Commanding the Modules |
| Gearing is a trade | A faster ratio raises top speed but lowers acceleration. The best one depends on how far the robot usually sprints. | Speed, Acceleration, and Traction |
| Slip current | The stator current at which the treads break loose. Above it, more current only spins the wheels. | Speed, Acceleration, and Traction |
Factor Graphs and GTSAM
Localization by solving for the recent trajectory at once. Factor graphs, factors for odometry, gyro, and tag corners in pixels, robust losses for bad measurements, and running GTSAM on an FRC robot.
Why Swerve
Tank, mecanum, and other FRC drivetrains compared. What a holonomic drive is, what swerve does better, and what it costs.