2702 Recipes

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.

Key ideas at a glance

IdeaOne-line summaryPage
HolonomicA swerve robot controls xx, yy, and heading separately. A tank robot has to turn to change direction.Why Swerve
Full traction in every directionMecanum wheels also move sideways, but push through rollers. Swerve turns the whole tread to face the direction of travel.Why Swerve
Absolute encoderThe 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 moduleEach module moves with the robot's center plus the turn rate times its distance from the center, turned 90°.Swerve Kinematics
Field-relativeRotate the driver's request by the gyro heading, so "up the stick" is always "up the field".Swerve Kinematics
Desaturate, don't clipIf 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 tradeA faster ratio raises top speed but lowers acceleration. The best one depends on how far the robot usually sprints.Speed, Acceleration, and Traction
Slip currentThe stator current at which the treads break loose. Above it, more current only spins the wheels.Speed, Acceleration, and Traction

On this page