Your First Swerve Robot
This tutorial takes a team from a bare WPILib project to a driving swerve robot using YAGSL. Follow the five steps in order — each one builds on the last, and by the end your robot will be driving under field-relative control with a tuned configuration.
Swerve drives are complicated and will not "just work" on the first try. If you've never brought up a swerve drive before, budget more than one sitting for this — gathering accurate information about your robot and calibrating hardware always takes longer than expected. If you've done this before, expect this tutorial to take about 30 minutes plus PID tuning time.
Prerequisites
A WPILib Command-Based Robot (Java) project (new or existing).
Your swerve modules are physically assembled and wired (motors, absolute encoders, gyroscope all on the robot).
You know how to deploy code to your robot and open a driver dashboard (Shuffleboard, Elastic, or AdvantageScope).
The five steps
Gather your robot information — collect the CAN IDs, gear ratios, and module locations you'll need before you touch any software.
Install YAGSL — add the YAGSL vendordep and any hardware vendordeps your robot needs.
Generate your configuration — use config.yagsl.com to turn your robot information into a config directory.
Verify and calibrate your hardware — confirm every motor, encoder, and gyro reports direction correctly, and capture absolute encoder offsets.
Deploy and drive — wire up
SwerveParserin a subsystem, bind your controller, and take your robot for its first drive.
Once you're driving, see the How-to Guides section for tuning PIDF gains, diagnosing drift, and other tasks you'll come back to as you keep developing.
Last updated
Was this helpful?