[iphone] Removing the influence of gravity on accelerometer readings

I have an app that reads acceleration data from the Y axis however when the device is tipped I get bogus readings due to gravity influence.

I'd like to combine the data from another axis (X I believe, I don't have the diagram handy) to negate this effect.

For example, if the phone is laying flat on its back, the Y axis should read 0 and the X axis should read 1g. If one end of the phone is then lifted, the reading on the Y axis should increase (if the top of the device is lifted) and the X axis should decrease.

So I should be able to combine these values mathematically and filter this effect from the "real" acceleration data I'm interested in the Y axis, correct?

I think there would be limits since I imagine beyond a certain point of deflection the readings from the Y accelerometer will become too inaccurate, but if I could compensate for minor changes in device angle that would be sufficient for my application.

I've tried a few approaches to this but either my math skills or some nonlinearity of the accelerometer are leading to unexpected results.

Is this possible, or is there an easier answer to this problem? Any ideas are appreciated.

Thanks!

iPod Touch, Mac OS X (10.5.5)

Posted on Oct 9, 2008 6:19 AM

Reply
7 replies

Oct 9, 2008 9:19 AM in response to Jason Gullickson

[https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPho neOSProgrammingGuide/AdvancedFeatures/chapter 11_section_2.html#//appleref/doc/uid/TP40007072-CH14-SW8]

Read the section titled "Isolating the Gravity Component From Acceleration Data"

actually it's "Isolating Instantaneous Motion From Acceleration Data"... it goes both ways! How clever...

Message was edited by: SexyAndOhSoWitty

Oct 9, 2008 10:37 AM in response to SexyAndOhSoWitty

Thank you for this link to the documentation. But I'm not sure this is exactly what I'm looking for.

If I understand this correctly, the high-pass filter will remove slowly-changing values but let sudden changes through. The low-pass filter will let slowly-changing values through, but block sudden changes. Is this correct?

If this is the case, I don't think this approach will work for my application. I need to measure both slow and sudden changes, but I need to reject changes that are caused when the device is moved off-axis and gravity begins to contaminate the readings. With only one axis I understand that this would be impossible, but I believe that by measuring the changes/difference between two axis it can be done. That's the theory anyway…

…but perhaps I'm mis-understanding the function of these filters?

Oct 9, 2008 10:44 AM in response to Jason Gullickson

Some basic trigonometry might help you understand the problem.

You have two sides of a force vector triangle, one is the force of gravity, the other is your accelerometer reading. Unless you have a 3rd known, for instance one of the angles, the triangle solution is ambiguous. You can't solve for the 3rd side. It could be almost anything (from the sum to the difference of the other two side lengths/accelerations).

First order low pass filtering just smoothes, or averages out, the readings of the acceleration value, it doesn't help you with any information about the unknown angle.

So you can't remove the influence of gravity from the accelerometer readings for arbitrary motion.

You could fix one of the angles of the unknown triangle by clamping the device such that it can't be tilted at all when moved. Then solving for acceleration is possible, because you would then have 2 sides plus one angle.

.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

[iphone] Removing the influence of gravity on accelerometer readings

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.