Swerve drive lets every wheel both spin and steer independently, so the robot can translate in any direction while rotating — a major maneuverability advantage for lining up Hub shots and weaving through traffic in REBUILT. It is more complex than tank drive, but modern libraries make it reachable for ambitious second-year teams.
How a module works. Each swerve module has two motors: a drive motor (speed) and a steering/azimuth motor (wheel angle), plus an absolute encoder (commonly a CANcoder) that knows the wheel's true heading even at power-on. A robot typically has four modules. Common COTS modules pair a Kraken X60 (integrated TalonFX) or NEO with an absolute encoder. The drivetrain also needs a gyro — the Pigeon 2.0 is a standard CTRE choice — to track field-relative heading.
The math, conceptually. Swerve kinematics takes a desired chassis motion (forward, strafe, rotate) and solves for each module's required speed and angle. WPILib provides SwerveDriveKinematics and SwerveModuleState for this, but writing it all from scratch is a big undertaking with many failure modes (offsets, inversions, gear ratios).
Why YAGSL. YAGSL (Yet Another Generic Swerve Library), developed by current and former BroncBotz (Team 3481) mentors, is designed so teams of all experience levels can run many types of swerve module from a JSON configuration instead of hundreds of lines of code. You describe your modules — motor types, CAN IDs, the absolute-encoder offset, gear ratios, wheel positions — in config files, and YAGSL handles the kinematics, odometry, and module control.
The single most important setup step is the absolute encoder offset: with the robot's wheels physically aligned forward, you record each encoder's reading and enter it as the offset so 'zero' means 'pointing forward'. Get this wrong and the robot drives in nonsensical directions — it is the classic first-swerve bug. After offsets, verify each module individually: command a small forward speed and confirm all four wheels point forward and roll the same direction.
The case study mindset. Many top teams now run swerve, but it is a deliberate jump in scope: more motors (8 vs 2), more CAN devices, tighter mechanical tolerances, and more to tune. The strategic question is honest — does omnidirectional movement win you enough in this game to justify the build and debugging cost over a well-executed tank drive? For a team ready for it, YAGSL plus quality COTS modules is a fast credible path, and pairing it with the AprilTag pose estimation from the next lesson unlocks automated alignment to the Hub.
Key takeaways
- Each swerve module has a drive motor, a steering motor, and an absolute encoder (e.g. CANcoder); four modules plus a gyro like the Pigeon 2.0 make a swerve drivetrain
- YAGSL configures swerve from JSON (motor types, CAN IDs, offsets, gear ratios) instead of hand-writing kinematics
- Setting the absolute-encoder offsets so 'zero = forward' is the critical first-swerve step; verify each module individually before driving
Keep going
Take the quiz · +10 XP with an accountMore in Advanced Techniques & Case Studies
Sources & corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed — publicly, in the corrections log.
Sources and further reading
- YAGSL Swerve Drive Docsdocs.yagsl.com
- YAGSL-Example (GitHub, BroncBotz)github.com
- Kinematics and Odometry (WPILib)docs.wpilib.org
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
- 13 min read
FRC Swerve Module Offsets: Calibration & Backwards Wheels
Zero your FRC swerve module offsets correctly, and fix wheels that spin backwards, modules that fight each other, and field-relative drive that feels rotated.
Read - 12 min read
FRC Swerve Modules Compared: MK4/MK4i, MAXSwerve, WCP & Thrifty
A practical FRC swerve module comparison: SDS MK4i and MK4n, REV MAXSwerve, WCP Swerve X2, and Thrifty Swerve on motors, wheels, ratios, and cost.
Read - 6 min read
Swerve Drive Explained: How FRC's Most Popular Drivetrain Works
A clear, beginner-friendly explanation of swerve drive in FRC — how the modules work, the math behind it, COTS options, and whether your team should run it.
Read
Lesson quiz
RequiredAll 3 right completes the lesson. Miss one and only that question comes back — anything you already answered correctly stays banked.
0 of 3 answered
01.How many independently controllable motors does a single swerve module typically contain?
02.What capability makes a swerve drive 'omnidirectional' compared to a tank/differential drive?
03.How does YAGSL (Yet Another Generic Swerve Library) primarily let teams configure their swerve drive?
Answer every question to submit.
All 28 lessons in Getting Started with FRC
- Not started:Project 1 — Make a NEO Spin with the REV Hardware Client
- Not started:Project 2 — Deploy a Real Arcade-Drive Program
- Not started:Project 3 — Refactor into a Command-Based Drive Subsystem
- Not started:Project 4 — Build a Fuel Launcher for REBUILT
- Not started:Project 5 — A One-Button Autonomous Routine
- Not started:The Connection Chain: When the Driver Station Won't Connect
- Not started:Brownouts: Why the Robot Goes Limp Mid-Match
- Not started:CAN Bus Gremlins: Missing and Conflicting Devices
- Not started:Software Gotchas: Inverted Drives, Scheduler Stalls, and Reading the RioLog
- Not started:Inspection-Day Failures: Bumpers, Size, and Weight
- Not started:Closed-Loop Control: PID + Feedforward for a Consistent Shot
- Not started:Swerve Drive: Omnidirectional Movement with YAGSL
- Not started:AprilTag Vision: Knowing Where You Are with PhotonVision
- Not started:Data-Driven Strategy: Scouting, EPA/OPR, and Alliance Selection
- Not started:Choosing Your Hardware Ecosystem: REV vs CTRE