Determine inversion
Work out which motors, encoders, and the gyro need to be inverted.
Swerve modules and swerve drives require some inversions to get working properly. The goal is to get everything to increase counter-clockwise positive (CCW+).
If your gears are grinding on the ground but not while on blocks, and your wheels are facing and spinning in the right directions, you may need to tune PID instead of inverting anything!
If you invert incorrectly, your modules or robot may spin "out of control." If nothing here resolves it, see The 8 steps.
All of the telemetry referenced below lives under Mechanisms/swerve in NetworkTables — see Telemetry, Simulation & Vision for the full tree.
1. Confirm the absolute encoder reads CCW+

With the robot lifted or on its side so the wheels spin freely, rotate one module by hand counterclockwise (viewed from directly above, robot front pointing away from you) and watch that module's modules/<name>/encoder value in AdvantageScope.
If it increases, the absolute encoder is already correct — leave
absoluteEncoderInvertedasfalse.If it decreases, set
absoluteEncoderInvertedtotruefor that module. This is rare — most absolute encoders already read CCW+ by default.
Once every module reads CCW+, rotate each wheel to point straight forward (bevel gear left) and record the modules/<name>/encoder value held in that position — that's the module's absoluteEncoderOffset. Enter it in the module's JSON, or paste it into config.yagsl.com.
2. Confirm the gyro reads CCW+
With the robot lifted off the ground, rotate the entire robot counterclockwise (viewed from above) and watch Mechanisms/swerve/gyro.
If it increases, leave
gyroInvertalone — there's nothing to change.If it decreases, set
gyroInverttotrueinswervedrive.json:
See the gyroscope reference for the full list of supported gyro.type values.
3. Spin test — catch drive motor inversion and module swaps
Still with the robot lifted off the ground, deploy code and drive with a joystick input that commands pure rotation (e.g. hold the rotation stick fully to one side). Watch the robot against AdvantageScope's Swerve widget (top-down view) — see Set up AdvantageScope — and compare:
Modules drift or translate instead of spinning cleanly in place
Wrong CAN IDs for a module, or a wrong absoluteEncoderOffset.
Spins cleanly, but the wrong way (clockwise instead of CCW)
Inverted drive motor(s); a diagonal module swap (front-left ↔ back-right, front-right ↔ back-left); or an absolute encoder offset captured with the bevel gear facing right instead of left.
If a single module is spinning the wrong way, invert that module's drive motor:
If every module spins the wrong way at once, double-check for a diagonal module swap in swervedrive.json's modules list before you start flipping individual inverted.drive fields — it's a more common cause than it sounds.
4. Field-orientation check
Once the spin test looks right, put the robot down and drive it forward/back/left/right at its starting heading while watching a 2D/3D Field tab fed from Mechanisms/swerve/pose. Then spin in place again, this time watching the field widget's heading instead of the swerve module widget.
Wrong at every heading, including the start: check
gyroInvert.Only wrong once you rotate away from the starting heading: an absolute encoder offset that's off, a drive motor inversion mistake, a wrong module
location, an absolute encoder wired to the wrong motor controller, or a wrong CAN ID. Verify wiring and CAN IDs first — they're the fastest to rule out.The spin test in step 3 looked right, but the field widget's heading spins backwards: an inverted gyro can flip the field widget even when the module states widget looked correct.
Last updated
Was this helpful?