Skip to content
2 min read
In progress

Gyros and IMUs: Pigeon 2.0, NavX2, and ADIS

The inertial sensors that measure heading, the difference between gyros and full IMUs, and the products teams use.

Lesson
27 / 51
Reward
+10XP

Sign in to track progress, earn XP, and save lessons.

A gyroscope measures angular rate (degrees per second). Integrate that rate over time and you get an angle. An IMU (Inertial Measurement Unit) combines gyros with accelerometers (and sometimes a magnetometer) to give a fuller picture of orientation: yaw, pitch, and roll.

Yaw, pitch, roll

Using aviation conventions: yaw is rotation about the vertical axis (which way the robot faces — the value you care about most), pitch is tilt forward/back, and roll is tilt side to side. For most FRC driving you use yaw; pitch/roll matter for balancing or detecting tipping.

Drift — the core challenge

Because angle comes from integrating rate, tiny rate errors accumulate into drift: the reported heading slowly wanders even when the robot is still. Common sources of drift include sensor bias and temperature change as the device warms up. You manage drift by:

  • Choosing a modern, low-drift IMU.
  • Following the manufacturer's recommended setup (some IMUs sample a zero-rate bias at boot and need stillness; others, like the Pigeon 2.0, do not).
  • Correcting heading periodically with absolute references (like AprilTags).
  • CTRE Pigeon 2.0 (CTR Electronics): a 9-degrees-of-freedom IMU on the CAN bus. Unlike the original Pigeon, it requires no on-boot calibration and no temperature calibration, and it does not need to be held still at boot — you get useful heading as soon as it powers on, with dramatically reduced drift. The only optional step is a one-time mount calibration in Phoenix Tuner X once placement is final. Read heading in Phoenix 6 with getYaw() or getRotation2d(). Its yaw is continuous (passes 360 to 361, not back to 0) and increases counter-clockwise viewed from the top (NWU convention for Rotation2d).
  • Kauai Labs NavX2 (navX2-MXP / navX2-Micro): a popular IMU that mounts to the roboRIO MXP port (SPI) or connects via USB/I2C, providing a fused yaw via its onboard AHRS.
  • Analog Devices ADIS16470 / ADIS16448: the ADIS16470 is a 6-DOF IMU (3-axis gyro + 3-axis accelerometer); the ADIS16448 adds a magnetometer and barometer (10-DOF). Both connect over SPI (typically via the MXP), and WPILib ships first-party classes for them.

Reading a gyro in WPILib

All of these expose a heading you can wrap in a Rotation2d. Convention check: WPILib expects counter-clockwise-positive yaw, so make sure your gyro's sign matches (invert if needed). A continuous, CCW-positive heading is what odometry and pose estimation expect.

Spot an error or something out of date?Log in to suggest an edit

Key takeaways

  • Gyros measure angular rate; integrating it gives heading, which slowly drifts (from bias and temperature).
  • The Pigeon 2.0 (CAN) needs no boot or temperature calibration and need not be still at boot; the NavX2 (SPI/USB) and ADIS16470 (SPI) are other common FRC IMUs.
  • WPILib expects continuous, counter-clockwise-positive yaw — verify the sign before using it in odometry.

Lesson quiz

Required

Answer all 3 questions correctly to complete this lesson.

01.How does the CTRE Pigeon 2.0 IMU communicate with the roboRIO?

02.Which set of sensors does the 9-degrees-of-freedom Pigeon 2.0 fuse to produce a heading?

03.What is a key advantage the Pigeon 2.0 has at boot-up compared to many older IMUs?

Answer every question to submit.

All 51 lessons in Programming, Controls & Sensors