View Full Version : accelerometer direction
mark2468
Jun24-10, 03:11 PM
Hi.
I have a problem using 3-axis accelerometer. I understand that the total acceleration is the square root of (x^2 + y^2 + z^2) but I cannot determine the direction of the acceleration.
Say the device is at 45 degrees and is moved straight up, how can this vertical motion be detected.
I can determine the angle/tilt of the device using trigonometry but cannot determine the linear motion in 3d. How can this be achieved, or is there any basic formula available.
Thanks,
Mark.
Accelerometer cannot determine motion at all, and will only measure acceleration relative to its own orientation. It cannot, for example, tell you the difference between being horizontal and accelerating horizontally, or being tilted and accelerating straight up. Both will give you the same acceleration in X, Y, and Z directions.
If you need to know acceleration in the world-coordinates, you need to know orientation relative to world.
broean01
Jun24-10, 03:29 PM
You'd probably be best off leaving the linear motion as a vector, but if you want angles, you could just convert to spherical coordinates (http://en.wikipedia.org/wiki/Spherical_coordinates)
mark2468
Jun24-10, 03:49 PM
Thanks for the reply's.
I do know the orientation relative to world, the problem is linear acceleration. Its easy get the acceleration in one direction if the other two dont move but what if it moves up at an angle or starts at an angle and moves straight up or straight across linearly.
"You'd probably be best off leaving the linear motion as a vector"
I am unable to determine the linear motion, how is this achieved??
Thanks again,
Mark.
If you know orientation, what's your problem? Are you simply asking how to transform a vector from one coordinate system to another? That is, take the x, y, z relative to accelerometer and transform to x, y, z relative to ground?
broean01
Jun24-10, 04:01 PM
Well if you represent the accelerometer's orientation as a unit vector, you can just perform a rotation on the acceleration vector opposite the rotation of the orientation vector. It winds up being easiest to do as quaternion multiplication
mark2468
Jun24-10, 04:09 PM
The problem is that I know the angle relative to ground (45 degrees in this case) but when the device is moved directly up I am unable so capture this as linear acceleration in the z direction because all 3 axis change.
This may seem trivial for some people but i am new to this.
Mark.
Lets say the 45° is rotation of Z axis towards X axis. Then:
a_x = \frac{a'_x+a'_z}{\sqrt{2}}
a_y = a'_y
a_z = \frac{a'_z-a'_x}{\sqrt{2}}
Where a' are the accelerations reported by accelerometer. Make sure to calibrate your axis appropriately, you should be measuring 9.8m/sē in negative z when the thing isn't accelerating.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.