Gyroscopes
Supported gyroscope/IMU types for swervedrive.json's gyro field
Hardware support narrowed in the 2026.8.05 rewrite. YAGSL now only instantiates gyros over CAN. The roboRIO SPI/I2C/USB-serial NavX (original NavX2 navx/navx_spi/navx_i2c/ navx_mxp_serial/navx_usb), the original CTRE Pigeon (gen 1), and the analog SPI gyros (ADXRS450, ADIS16448, ADIS16470) are not supported by the current parser. If your robot uses one of those devices, see Schema Changes — you'll need to either move to a supported CAN gyro or use the custom gyro type below to keep wiring it up yourself.
Gyroscope Checklist
Configuring the gyro
In swervedrive.json the gyro is one object plus two drive-wide settings:
{
"gyro": {
"type": "pigeon2_can",
"id": 13,
"canbus": "canivore"
},
"gyroAxis": "yaw",
"gyroInvert": true,
"modules": ["frontleft.json", "frontright.json", "backleft.json", "backright.json"]
}gyro.type— one of the supported types below, formattedvendor_connection, orcustomto configure the gyro yourself (see Custom Gyro).gyro.id— CAN ID of the device (ignored where not applicable).gyro.canbus— CAN bus name. Use""for your control system's default bus (rioon a roboRIO), or a CANivore name if the device is on one — see Control system and CAN buses.gyroAxis— which physical axis of the sensor to read as robot heading:yaw(default),pitch, orroll. Only change this if the sensor is mounted on an edge or angle.gyroInvert— invert the heading reading. If your robot spins out of control with no controller input, invert this.
Only CTRE devices support the canbus option for a CANivore. If your device is on your control system's default CAN bus (rio on a roboRIO), use "". If it's on a CANivore, canbus must match the CANivore's configured name.
Supported gyroscope types
Device
type
Communication
SystemCore internal IMU
systemcore_internal
listed in the config schema but not yet implemented — the parser throws if selected. Do not use yet.
If you need a gyro not on this list — including the older roboRIO SPI/I2C/USB-serial NavX (AHRS) devices called out in the hint above, which the CAN-only parser no longer builds — use the custom type below.
Custom Gyro
Set gyro.type to custom and YAGSL's parser skips gyro configuration entirely: it never calls SwerveDriveConfig.withGyro()/withGyroInverted(), and gyroAxis/gyroInvert in swervedrive.json are ignored. You're expected to call withGyro()/withGyroInverted() yourself on the SwerveDriveConfig you pass into SwerveParser.createSwerveDrive(...) — everything else in the config (modules, motor controllers, encoders) is still built normally from the JSON.
This is the escape hatch for any gyro the parser doesn't build for you — most commonly the roboRIO SPI-mounted Studica AHRS (the classic NavX2), since only the CAN-based NavX3 is supported directly.
Because withGyroInverted() is never called by the parser for a custom gyro, do any inversion you need directly in the Supplier<Angle> you pass to withGyro(), as shown above.
NavX3-CAN
Checklist
NavX3-CAN ships factory-calibrated. For higher accuracy, re-calibrate with Studica Hardware Manager — it auto-detects sensor orientation during calibration. Connect CAN-H/CAN-L to the robot bus and make sure the bus is properly terminated.
Pigeon 2
Upgradeable via Tuner X — pay attention to the LED status code when debugging. Any settings changed in Tuner X are overwritten on startup by YAGSL.
Checklist
Communicates over CAN and can be paired with a CANivore to keep it off your control system's default CAN bus — set a CANivore name and use it as canbus.
Canandgyro
CAN only; does not support CANivore.
General gyro tips (still apply regardless of device)
Mount the gyro as close to the robot's center of rotation as practical — off-center mounting couples translational vibration into the heading reading.
Always keep the robot still for a few seconds after power-on if your device does an on-the-fly calibration; moving during that window produces a bad heading for the rest of the match.
If the robot's heading drifts over a match, see Swerve Drive Drift Causes.
Last updated
Was this helpful?