Using accelerometer data to correct for gyro drift

November 14, 2011

Gyroscopes do not measure acceleration, so they obviously cannot be used to calculate the direction of gravity. In other words, we can use gyro outputs to calculate an estimation of the direction cosine matrix, but the estimate will drift over time. A 3-axis accelerometer can be used to correct the roll and pitch drift, which is important in keeping the craft at least upright.

In order to achieve this, we wish to keep the global K vector codirectional with the negative gravity vector. That is, the cross product of the two vectors should equal zero, and we can use whatever the cross product actually is as our correctional rotation vector. It is important to keep in mind, however, that since the accelerometer reports acceleration in the body frame of reference, we must express K in the same frame of reference as the acceleration vector.

This body frame K vector is simply found by taking the third row of the transpose of the DCM we found earlier. We cross multiply K with the gravity vector, add the resulting correction vector to the angular displacement vector, and take a weighted average. Where wdt is the angular displacement vector (w * dt) and wA is the correction vector, we can recalculate wdt:

An added benefit to using an accelerometer to correct for gyro drift is that we can initialize the IMU in any orientation and the DCM will tilt to agree with whatever the accelerometer thinks is up and down. On the flipside, this could be dangerous if the accelerometer is mounted to the chassis improperly (i.e., not perfectly in line with the robot’s vertical axis), but that can be remedied by careful setting of static offsets in code.