Question

I am trying to determine the benefit of making use of Android's Linear Acceleration data as opposed to simply applying a low pass filter as presented in Androids API reference and discussed in this other stackoverflow question.

I am asking as I am trying to get hold of a free app that records Linear Acceleration (as well as fullfils my other requirements (sampling rate, writing data to file etc...)). I haven't been able to find one, so I have considered just using an app that records using the standard accelerometer and then I'll simply apply the low pass filter to the data. Alternatively I could just write my own app to do what I need - but I don't have much experience in Android dev and this will take some time.

Was it helpful?

Solution

I have explored this subject at some length and I may be able to help point you in the right direction.

As others have mentioned, only some phones have implemented TYPE_LINEAR_ACCELERATION and TYPE_GRAVITY and they usually are equipped with a gyroscope. A Droid Razr even has a gyroscope, but they never bothered to implement it or TYPE_LINEAR_ACCELERATION. I believe the GS2 has TYPE_LINEAR_ACCELERATION implemented, but no gyroscope so they must have used the magnetic sensor or some sort of low-pass filter. It can be frustrating.

On most phones with a gyroscope there is some sort of fusion between the acceleration sensor and gyroscope (probably a complementary filter to compensate for drift and then quaternions or cardan angles to isolate gravity). These fusions and filters can be implemented differently and use different hardware, etc... Latency and accuracy are going to vary among devices, so TYPE_LINEAR_ACCELERATION isn't always going to produce the same results.

If you do not have a phone with TYPE_LINEAR_ACCELERATION, you are stuck with TYPE_ACCELERATION, which cannot separate gravity (tilt) from linear acceleration.

One option is to apply the low-pass filter. This may or may not work depending on your application. I have written a free application to help developers and other interested parties explore the low-pass filter option.

Another option is to just measure the tilt of the device when it is static and then apply that gravity measurement while the device is not static. If the device isn't changing the orientation often, this can be an excellent option because it is really fast and simple.

An excellent alternative sensor fusion option is to use the magnetic sensor instead of a gyroscope. This option will work on almost all devices assuming the magnetic field isn't under the effects of hard or soft iron distortions.

I have implemented all of these approaches in the open source project Acceleration Explorer

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top