For the complete documentation index, see llms.txt. This page is also available as Markdown.

Verify and calibrate your hardware

Before your first drive, confirm every sensor and motor reports direction consistently, and capture each module's absolute encoder offset. Skipping this step is the single most common cause of a swerve drive that "spins out" or drives in the wrong direction.

Physically label everything

Label each motor controller, encoder, and gyroscope with its CAN ID/channel and connection type before you start. This is the easiest step to get wrong and the hardest mistake to spot afterward.

Check your gyroscope

  • Front is whatever the gyroscope reports as 0. Pick a front, and expect that you may need to change it later if it turns out to be inconvenient.

  • The gyroscope must report increasing yaw while the robot rotates counterclockwise. If it doesn't, invert it.

  • If you're using a NavX, recalibrate it once it arrives at your shop — NavX units ship calibrated to the humidity of their factory, not your build space. Recalibrate again periodically, especially at competition.

Check your motors

Deploy your code with the config from step 3, then — with the robot disabled — spin each motor by hand and watch AdvantageScope's Mechanisms/swerve NetworkTables tree.

The Mechanisms/swerve tree in AdvantageScope — each module's drive/azimuth telemetry and raw absolute encoder are visible per-module.
  • Rotate the drive wheel forward (CCW as viewed from above). That module's modules/<name>/drive/mechanism/position should increase. If it doesn't, invert the drive motor.

  • Rotate the angle mechanism CCW (viewed from above). Both modules/<name>/azimuth/mechanism/position (relative) and modules/<name>/encoder (absolute) should increase. If either doesn't, invert that motor or encoder respectively.

  • Rotate the entire robot CCW. Mechanisms/swerve/gyro should increase. If not, invert the gyroscope.

See Determine Inversion for the full decision procedure if any of these don't behave as expected — or work through config.yagsl.com/guide, which walks through this same alignment process interactively.

Capture absolute encoder offsets

The absolute encoder offset is what lets your swerve module remember wheel orientation across power cycles — it's essential to a functioning swerve drive.

  1. Manually rotate all four wheels so they point in the same direction — bevel gears facing left, as in the diagram below — and forward rotation increases the drive encoder.

The left and right are physical left and right.
  1. With the robot still disabled, open AdvantageScope and read each module's Mechanisms/swerve/modules/<name>/encoder value while it's held in that aligned position.

  2. Enter each value as that module's absolute encoder offset — either back in the config generator (recommended: upload your existing config, update the four offset fields, and re-download) or directly in absoluteEncoderOffset in the module's JSON file.

Once every module reports correctly and has a captured offset, move on to deploying and driving.

Last updated

Was this helpful?