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 navX-MXP, 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-MXP, Quantization error is minimized due to the MPU-9250’s internal signal conditioning, high-resolution 16-bit Analog-to-Digital Converters (ADC), and extremely fast internal sampling (200Hz). Scale factor error is easily corrected for by factory calibration, which the navX-MXP provides. So these two noise sources are not significant in the navX-MXP.
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 the MPU-9250.
- Temperature instability can cause major amounts of error, and should be managed to get the best result. To address this, the MPU-9250 automatically re-calibrates the gyro biases whenever it is still for 8 seconds, which helps manages temperature instability.
Errors in the navX-MXP Pitch and Roll values to be 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-MXP 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 navX-MXP circuit board uses the Invensense MPU-9250 IC, and this IC implements a proprietary algorithm which is widely believed to be an EKF (it exhibits similar accuracy to documented EKF implementations on MEMS acceleromter/gyroscope sensors).
With this processing, navX-MXP exhibits yaw drift on the order of ~1 degree per minute; yaw drift is typically much lower when navX-MXP is still.
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 calculation:
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-MXP RoboRIO libraries is to periodically “re-zero” navX-MXP by applying an offset to the navX-MXP 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-MXP 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-MXP provides a 9-axis “fused heading” which is combined with the ~1 degree per minute of 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.