[Physics] How to calculate the horizontal acceleration

acceleration

I am trying to measure the acceleration and deceleration of a car by using an 3 axis accelerometer which is build in an iPhone 5s. Placing the iPhone flat inside the car with the y axis to the top of the car this works pretty ok. But now I want to be able to place the iPhone basically arbitrary inside the car. (like in the picture below)

iPhone inside a car
(source: everythingicafe.com)

Is there a way to calculate only the horizontal acceleration of the device in such a placement? (I am aware that you won't be able to differ a directional acceleration but that's sufficent for my project. If I am wrong, I would be glad to know if it would work)

To do the calculations the following data is available

  • User Acceleration (uX,uY,uZ) – only the acceleration the user imparts to the device
  • the total acceleration of the device (tX,tY,tZ) – user acceleration plus gravity
  • Gyro Data (gX,gY,gZ) – the device’s rate of rotation around it's axes
  • the attitude of the device (quaternion, rotation matrix, (pitch,roll,yaw))

Many thanks in advance!

Best Answer

If you don't care about the direction of the horizontal acceleration, the answer is yes.

When the car is stationary (user acceleration very small, below some limit you define for the RMS of the three axes) you measure the vector $\vec g$ for the total acceleration - this is "down".

Now during motion you find the user acceleration perpendicular to this vector with these steps:

Normalize $\vec g$ to unit length: $\vec n$

Take dot product of unit gravity and user acceleration: $d=\vec n \cdot \vec u$

Subtract vertical component from user acceleration: $\vec h = \vec u - d \vec n$

Finally take the magnitude of this answer (square root of sum of squares of components) for the total horizontal acceleration.

To separate out the acceleration into lateral (from car turning) and linear (accelerate/brake) you would have to do a similar procedure to find the remaining orientation by looking for horizontal acceleration when there is no corresponding rotation - this tells you which way the phone is facing.

Related Question