A gyroscope measures the amount of angular rotation about a single axis. Since the gyroscope measures changes in angular rotation, rather than an absolute angle, calculation of the actual current angle of that axis is estimated via numerical integration rather than an exact measurement.
Any Inertial Measurement Unit (IMU), including a navX-sensor, that integrates a signal from a gyroscope will also accumulate error over time. Accumulated error is due to several factors, including:
- Quantization noise (which occurs when an analog-to-digital converter (ADC) converts a continuous analog value to a discrete integral value)
- Scale factor error (which occurs due to manufacturing errors causing a specified scale factor [e.g., 256 bits per unit G] to be incorrect)
- Temperature instability (which occurs when a sensor is more or less sensitive to an input as temperature changes)
- Bias error (which occurs because the value the sensor reports at ‘zero’ is not known well enough to ‘subtract’ that value out during signal processing)
Over time, these errors accumulate leading to greater and greater amounts of error.
With the navX-sensor, Quantization error is minimized due to internal signal conditioning, high-resolution 16-bit Analog-to-Digital Converters (ADC), and extremely fast internal sampling (416Hz). Scale factor error is easily corrected for by factory calibration, which the navX-sensor provides. So these two noise sources are not significant in a navX-sensor.
The remaining sources of error – temperature instability and bias error – are more challenging to overcome:
- Gyro bias error is a major contributor to yaw drift error, but is inherent in modern MEMS-based gyroscopes like those used in a navX-sensor.
- Temperature instability can cause major amounts of error, and should be managed to get the best result. To address this, navX-sensors automatically re-calibrate the gyro biases whenever it is still for several seconds, which helps manages temperature instability.
Errors in the navX-sensor Pitch and Roll values are small – these angles are extremely accurate over time since gyroscope values in the pitch/roll axes can be compared to the corresponding values from the accelerometer. This is because when navX-sensor is still, the accelerometer data reflects only the linear acceleration due to gravity.
Correcting for integration error in the Yaw axis is more complicated, since the accelerometer values in this axis are the same no matter how much yaw rotation exists.
To deal with this, several different “data fusion” algorithms have been developed, including:
- Complementary filter
- Extended Kalman filter (EKF)
- Direction Cosine Matrix filter (DCM)
Note: See the References page for links to more information on these algorithms.
These algorithms combine the acceleromter and gyroscope data together to reduce errors.
The Complementary and EKF filter algorithms are designed to process 3-axis accelerometer and 3-axis gyroscope values and yield yaw/pitch/roll values. The Complementary filter is a simple approach, and works rather well, however the response time is somewhat slower than the EKF, and the accuracy is somewhat lower.
The DCM filtering approach is similarly accurate and responsive as the EKF, however it requires information from a 3-axis magnetometer as well to work correctly. Since the magnetometer on a FIRST FRC robot typically experiences significant amounts of magnetic disturbance, the DCM algorithm is not well suited for use in a Robotics Navigation Sensor.
For these reasons, the EKF is the preferred filtering algorithm to provide the highest performance IMU on a FIRST FRC robot. However, the EKF algorithm is complex and difficult to understand, making it typically beyond the capabilities of many robotics engineers. The “Generation 2” navX-sensors implement an Extended Kalman Filter that runs at 416 Khz and yields extremely accurate results. The older “Classic” navX-MXP sensors used the Invensense MPU-9250 IC, which internally implemented a proprietary algorithm widely believed to be an EKF (it exhibits similar accuracy to documented EKF implementations on MEMS acceleromter/gyroscope sensors).
With this processing, navX-sensors exhibit very low yaw drift as documented in the Technical Specifications.
Tips
What follows are some tips on how to deal with the yaw drift within the context of a FIRST FRC competition.
In general, the yaw will not drift significantly during a FRC match, based upon the following calculations:
“Generation 2” navX-sensors:
yaw drift(degrees) at end of match = yaw drift (~.5 degree/minute) x match length (2.5 minute) = ~1.25 degrees or better
“Classic” navX-sensors:
yaw drift(degrees) at end of match = yaw drift (~1 degree/minute) x match length (2.5 minute) = ~2.5 degrees
However, during long practice matches the drift may become noticeable, and can be dealt with using the following approaches:
1) The simplest approach which is supported by the navX-sensor libraries is to periodically “re-zero” navX-sensor by applying an offset to the navX-sensor yaw angle. To use this approach, when the robot is in the correct orientation, a driver can press a button which causes an offset to be added so that the reported angle at that orientation is 0.
2) Even though the navX-sensor magnetometer will likely give erroneous readings once the robot motors are energized, a calibrated magnetometer can potentially provide a stable reading during the moments before a FRC competition round. The navX-sensor provides a 9-axis “fused heading” which is combined with the drift in the yaw angles. Using the “fused heading”, it is possible to calculate the robots absolute orientation and maintain it. With the “fused heading”, that drift will be updated w/the absolute heading from the compass whenever a compass reading which is free from magnetic disturbance is detected. Note that to be effective this requires the magnetometer to be calibrated. Once calibrated, an initial magnetometer reading undisturbed by magnetic disturbances can be acquired at the beginning of a match, before the motors are energized. If the sensor is placed far enough away from motors, it may be possible to also get an undisturbed magnetometer during a match. Finally, note that the resulting angle is only as accurate as the magnetometer calibration and magnetometer accuracy allow.
In practice, FRC teams find that approach 1) is preferred, and given the enhanced accuracy of “Generation 2” sensors this is definitely the recommended approach.