The application’s sensor fusion relies on quaternion linear
interpolation to combine the gyroscope, accelerometer and
magnetometer data. Gyroscopes suffer from drift but produce
noise-free data at high frequencies. Accelerometers and magnetometers
can be combined to produce a rough approximation
of rotation. The resulting signal contains no noticeable drift
but oscillates in excess of one degree per frame of motion.
The three sensors can be fused so that the accelerometer and
magnetometer are used by the gyroscope as a reference point
to cancel drift. The entire motion processing can be divided in
three separate stages: data preparation, drift cancellation and
post-processing