-1

I am developing an application in android that needs to determine the amount of acceleration in a car when braking. I have found out how to get the pitch and roll angles, but I am at a loss on how to calculate the relative acceleration coordinates using the angles.

For instance, if the device is sitting in a dock on the dash board, it is tilted forward at 15deg and tilted sideways at 5deg. When the person hits the brakes the acceleration due to braking will be distributed between the X, Y and Z axis. How do I use the pitch and roll to determine the acceleration in the Z direction relative to the earth?

I have included a picture for reference: In the picture I am trying to calculate Z(prime) based just off of the Y and Z axis, however in the real world, I will also need to use the X axis and also calculate Y(prime) and X(prime).

Thank you for your help. (and sorry for the bad handwriting) enter image description here

3
  • You can't do this using tilt. You don't know what the phone is mounted to. Imagine a tripod bolted to the floor. The tripod has a rubber mount for the the phone. Now decelerate at -5ms per second squared. What is the tilt angle? Now replace the mount with a steel one and apply the same decelarative force. The tilt will be different. Now, factor in the effect of the suspension in preventing weight shifting to the front wheels (the tilt of the car) and tyre pressure etc etc. Every mount in every car will need calibrating with a device which accurately measures force.
    – Simon
    Jan 3, 2013 at 22:36
  • I am using the gravity sensor to help prevent this effect. The gravity sensor, will help to isolate the acceleration to only see the linear acceleration. No matter the suspension, the acceleration has to go somewhere, it will just be normalized in more directions.
    – Reid
    Jan 3, 2013 at 22:38
  • Check out this link: stackoverflow.com/a/2318356/1851478
    – logray
    Jan 3, 2013 at 23:55

4 Answers 4

1

How you are finding the moving direction ? Just take sqrt(x^2+y^2+z^2) -9.81) its is enough because you all the acceleration on phone is due to car.If possible apply low pass filter to remove changes due to road bumps .

1

You don't have to do anything, it has already been done for you.

Use the Linear Accelerometer.

0

Use Accelerometer not Orientation sensor.

Here is some nice PDF where you can find what you want, some differences between them and how to use them.

Is it what you want?

http://www.touchqode.com/misc/20101025_jsug/20101025_touchqode_sensors.pdf

3
  • I am using the accelerometer, I am just unsure on how to normalize the devices accelerometer relative to the earths surface.
    – Reid
    Jan 3, 2013 at 22:31
  • 1
    Accelerometer returns you values of acceleration relative to earth in m/s^2.
    – InflexCZE
    Jan 3, 2013 at 22:34
  • Correct, but once gravity is subtracted dynamically from the acceleration using the GRAVITY sensor, the acceleration in m/s^2 is shown as the remaining values in each of the 3 axis. I am unsure on how to combine theses 3 values to a single normal one.
    – Reid
    Jan 3, 2013 at 22:37
0

If I understand your question correctly you can get it with this code:

g = FloatMath.sqrt(x * x + y * y + z * z);

here g will be the given G-force in all directions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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