1
$\begingroup$

I'm currently working on a project that involves calculating a sensor module's distance and orientation. The problem I'm running into is the fact that once the sensor is, for example, rotated around its pitch axis, gravity starts pulling on the sensor's X axis, causing the measured X acceleration to go up even though the sensor is motionless. So I am looking for a way to dynamically subtract gravity's influence from the, depending on the sensor's rotation, desired accelerations.

So my question is: If I were to know an objects yaw/pitch/roll and its acceleration in all three different axis, how can I subtract gravity's influence from its three different accelerations in any orientation?

Any help would be highly appreciated!

EDIT: Hopefully made the case and question a little more clear :).

  • 0
    Dear Steven, a detail, a typo: the operation is called "subtraction", not "substraction". ;-) Unfortunately, I don't understand what the question wants to say unless your desire is to subtract one 3-vector from another 3-vector.2011-05-23

1 Answers 1

1

If I'm reading this right, you want to know how gravity influences your sensor based on its rotation and then remove the effect of that influence. I think the best way to go about this is to rotate the gravity vector to correspond with your sensor's rotation and then add the vector that is opposite in magnitude to add out gravity. Like so:

Let $\vec{G} = \langle 0, 0, g \rangle$ where $g$ is the force of gravity, typically $-9.81 ^{m}/_{s}$.

The matrix for rotating a vector by pitch $\alpha$, yaw $\beta$, and roll $\gamma$ is: (from http://planning.cs.uiuc.edu/node102.html).

$$ \begin{equation} \begin{split} R(\alpha,& \beta,\gamma) = R_z(\alpha) \, R_y(\beta) \, R_x(\gamma) = \\ & \begin{pmatrix} \cos\alpha \cos\beta & \cos\alpha \sin\beta \sin\gamma - \sin\alpha \cos\gamma & \cos\alpha \sin\beta \cos\gamma + \sin\alpha \sin\gamma \\ \sin\alpha \cos\beta & \sin\alpha \sin\beta \sin\gamma + \cos\alpha \cos\gamma & \sin\alpha \sin\beta \cos\gamma - \cos\alpha \sin\gamma \\ -\sin\beta & \cos\beta \sin\gamma & \cos\beta \cos\gamma \\ \end{pmatrix}. \end{split} \end{equation} $$

Thus, the transformed gravity vector is:
$\vec{G}\,' = \vec{G}*R(\alpha, \beta,\gamma) = \langle -g \sin(\beta) , \;\; g \cos(\beta) \sin(\gamma) , \;\; g \cos(\beta) \cos(\gamma) \rangle$

You can then take your acceleration vector $\vec{A}$ and add the vector of opposite magnitude, which is the same as subtracting $\vec{G}\,'$. Thus, your final formula is:

$\vec{A}\,' = \vec{A} - \langle -g \sin(\beta) , \;\; g \cos(\beta) \sin(\gamma) , \;\; g \cos(\beta) \cos(\gamma) \rangle$

Is that what you want?

EDIT2: This matrix depends on the order in which rotations are applied.

  • 0
    @Steven: You're quite welcome. :)2011-05-24