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).
The popular FRC IMUs
- 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()orgetRotation2d(). Its yaw is continuous (passes 360 to 361, not back to 0) and increases counter-clockwise viewed from the top (NWU convention forRotation2d). - 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.
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.
Keep going
Take the quiz · +10 XP with an accountMore in Gyros, IMUs, and Orientation
Sources & corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed — publicly, in the corrections log.
Sources and further reading
- WPILib: Gyroscopes (hardware)docs.wpilib.org
- CTRE Pigeon 2.0 (Phoenix 6 docs)v6.docs.ctr-electronics.com
- Kauai Labs NavX2pdocs.kauailabs.com
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
- 17 min read
FRC Sensors Explained: Encoders, Gyros, Beam Breaks, and Limit Switches
A practical FRC guide to encoders (quadrature, absolute, CANcoder, through-bore), gyros (NavX2, Pigeon 2.0), limit switches, beam breaks, and current sensing.
Read - 18 min read
CTRE Phoenix for FRC: Kraken X60/X44, TalonFX, Phoenix 6, CANcoder & Pigeon 2
A practical guide to the CTRE Phoenix ecosystem for FRC: Kraken X60/X44 motors, TalonFX, Phoenix 6 API, Pro/FOC licensing, CANcoder, Pigeon 2 & CANivore.
Read - 15 min read
FRC Odometry and Pose Estimation: Field-Centric Control with WPILib
How an FRC robot tracks its field position with WPILib: wheel odometry vs pose estimation, gyro heading, fusing AprilTag vision, and field-centric driving.
Read
Lesson quiz
RequiredAll 3 right completes the lesson. Miss one and only that question comes back — anything you already answered correctly stays banked.
0 of 3 answered
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
- Not started:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not started:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not started:Mini-Project: A Teleop Swerve Drive Subsystem
- Not started:Mini-Project: An Autonomous Routine with PathPlanner
- Not started:Mini-Project: Vision-Aligned Scoring with Limelight
- Not started:State-Space Control and Kalman Filtering
- Not started:Log Replay Architecture with AdvantageKit
- Not started:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not started:Robot Coordination, Alerts, and Operator Feedback
- Not started:Case Study: Hardening Software Before an Event