I'm trying to develop a 3D position estimation program using an xyz accelerometer. Ignoring the massive error introduced by double integration of the acceleration to get displacement, I have another problem with rotation.

When the phone is upright I have no problems. I can stand the phone straight up and move it side to side on the desk on the x-axis alone to get the desired values. The issue is if the phone is tilted slightly (say 45 degrees) and again moved side to side. Internally the phone thinks it's moving in a diagonal direction on both x and y axes.

Since the phone is actually just moving on the x-axis, is it possible to use the tilt angle to modify the x and y values so that x is the actual acceleration in the x-axis and y is 0?

To clarify, imagine the phone is set at a 45 degree angle and moved right at a speed of 1ms-2. The x and y accelerometer values will both read ~0.71. I can use the SOH CAH TOA rules to get an x value of 1, which is what I wanted. However I can't see how I can get the y value to 0.

  • $\begingroup$ If the phone is free to rotate, than you need gyroscope too. For example you can't determine if the phone is rotating around vertical axis or not. So do you have at your disposal full 3 axis gyroscope? $\endgroup$ – tom Apr 24 '14 at 11:45
  • $\begingroup$ I have a 3 axis gyroscope built in, and I do intend to fuse that with the accelerometer, but I'm not worrying about that for now. Right now I'm assuming that the phone is fixed at any given angle. $\endgroup$ – karoma Apr 24 '14 at 12:05

Phone is rotated by $45°$ and accelerating in x-direction at rate $1ms^{-2}$. The accelerometer is reading acceleration in coordinate frame fixed with phone so it reads acceleration $\left(\frac{\sqrt{2}}{2},\frac{\sqrt{2}}{2}\right)ms^{-2}$ to transform acceleration from phone's local frame to world frame you just do matrix multiplication $$ \left( \begin{matrix} \cos{45} & \sin{45} \\ -\sin{45} & \cos{45} \end{matrix} \right) \left( \begin{matrix} \frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{2} \end{matrix} \right) = \left( \begin{matrix} 1 \\ 0 \end{matrix} \right) $$

Of course you can change $45$ to any angle you wish.

  • $\begingroup$ Is this the answer you are after? $\endgroup$ – tom Apr 24 '14 at 13:35
  • $\begingroup$ It sure is. Many thanks. $\endgroup$ – karoma Apr 24 '14 at 13:42
  • $\begingroup$ Ahh that is unfortunate. Because the question when the phone is free to rotate is much more interesting. $\endgroup$ – tom Apr 24 '14 at 23:51
  • $\begingroup$ Well I'm getting accelerometer data every 0.01 seconds. At any given 0.01 second interval I can get the rotation and use that to calculate the world vector for that precise moment. If the rotation changes from one interval to the next, won't the above still apply? $\endgroup$ – karoma Apr 25 '14 at 8:15
  • $\begingroup$ Yes you can, the situation in 2d is simple but when you go to 3d everything gets more complicated. $\endgroup$ – tom Apr 25 '14 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.