Accelerometer Gravity Subtraction
Body forces on the microstructure add gravitational acceleration to the measurements and it appears as if the body is accelerating off in one direction, even though it is not. The goal is to devise a method to isolate the linear acceleration from the gravitational acceleration with a method that is robust even for large accelerations.
If there is an initial calibration cycle, and a gyroscope is paired with the accelerometer, we can effectively keep track of the gravitational vector even as the accelerometer rotates. Note that if the gyroscope does not drift, or has an algorithm to combine it with yet another sensor for reference orientation, the acceleration can be measured with respect to the inertial frame indefinitely.
Below is the flow diagram for the data collection process. In theory, the process is very simple. However, in practice, problems such as drift and noise can skew the measurements, techniques to overcome this will be discussed later.
Now that the overview is complete, the implementation will be discussed. You will need knowledge of quaternion multiplication, integration, and addition of vectors.
Suppose we can measure the angular velocity in its three components.
$$ \omega = [ \omega_x , \omega_y , \omega_z ] $$
With this vector, integration can be performed to get the new quaternion of rotation. Since this is a standard operation, I will not discuss it, but you can visit this link to get more information as well as a derivation. If the link is broken, you can also download the PDF file here.
Of course with any integration, we must define the initial state (in this case quaternion) \(q_0\)
Assuming that you understand how to generate and update quaternions with angular velocity readings, you can start at the "Calibration" heading in the PDF below which discusses how quaternions can be used to rotate vectors.