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.
the part worth keeping
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.
Programming, Controls & SensorsGyros, IMUs, and Orientationlesson 1 of 3
Keep going
Take the quiz+10 XP with an accountMore in Gyros, IMUs, and Orientation
where this came from
Sources and 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, in public, in the corrections log.
sources and further reading
- docs.wpilib.orgWPILib: Gyroscopes (hardware)
- v6.docs.ctr-electronics.comCTRE Pigeon 2.0 (Phoenix 6 docs)
- pdocs.kauailabs.comKauai Labs NavX2
clipped to this lesson
Articles that go further on this
The lesson gets you through the topic. These go wider on it, and they read in one sitting.
- 17 min readFRC Sensors Explained: Encoders, Gyros, Beam Breaks, and Limit SwitchesA practical FRC guide to encoders (quadrature, absolute, CANcoder, through-bore), gyros (NavX2, Pigeon 2.0), limit switches, beam breaks, and current sensing./blogread it
- 18 min readCTRE Phoenix for FRC: Kraken X60/X44, TalonFX, Phoenix 6, CANcoder & Pigeon 2A practical guide to the CTRE Phoenix ecosystem for FRC: Kraken X60/X44 motors, TalonFX, Phoenix 6 API, Pro/FOC licensing, CANcoder, Pigeon 2 & CANivore./blogread it
- 15 min readFRC Odometry and Pose Estimation: Field-Centric Control with WPILibHow an FRC robot tracks its field position with WPILib: wheel odometry vs pose estimation, gyro heading, fusing AprilTag vision, and field-centric driving./blogread it
answer sheet
Lesson quiz
All 3 right completes the lesson. Miss one and only that question comes back, anything you already answered correctly stays banked.
0 of 3 answered
01How does the CTRE Pigeon 2.0 IMU communicate with the roboRIO?
02Which set of sensors does the 9-degrees-of-freedom Pigeon 2.0 fuse to produce a heading?
03What 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 & Sensorsopenclose
01 / prerequisites
02 / foundations-tools-and-first-program
03 / robot-program-and-command-based
04 / motors-and-control
05 / autonomous-trajectories-simulation
06 / sensing-fundamentals
07 / encoders
08 / gyros-imus-orientation
09 / closed-loop-control
10 / vision-pose-estimation
11 / worked-examples-mini-projects
- Not read yet:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not read yet:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not read yet:Mini-Project: A Teleop Swerve Drive Subsystem
- Not read yet:Mini-Project: An Autonomous Routine with PathPlanner
- Not read yet:Mini-Project: Vision-Aligned Scoring with Limelight
12 / common-mistakes-troubleshooting
13 / advanced-techniques-case-studies
- Not read yet:State-Space Control and Kalman Filtering
- Not read yet:Log Replay Architecture with AdvantageKit
- Not read yet:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not read yet:Robot Coordination, Alerts, and Operator Feedback
- Not read yet:Case Study: Hardening Software Before an Event