Following is the algorithm Accelerometer measures combined gravity Rg and device acceleration Ra:
Rag = Rg + Ra
We’re seeking to find acceleration Ra, we know Rag (as measured by accelerometer), but we don’t know Rg or Ra.
We can calculate Rg for example by using a magnetometer and using the fact that Rg (gravity vector) can be obtained by rotating Mn (magnetometer North vector) by 90 degrees about Y axis.
Rg = Tn * Mn , where Tn is the DCM rotation matrix see http://en.wikipedia.org/wiki/Rotation_matrix, determined by calibration
Ra = Rag – Rg = Rag – Tn * Mn
Can anyone provide sample code or maths of this calculation?Can it can be done gyro instead of magnometer?