Using Android's Linear Acceleration versus applying a low pass filter
Asked Answered
E

1

6

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.

Egon answered 23/6, 2013 at 17:16 Comment(3)
The low-pass filter is usually a bad idea, especially if you have access to the linear acceleration. What would you like to do? Why do you need the acceleration?Sarcocarp
I am simply trying to record and analyze typical acceleration profiles when performing simultaneous actions. Luckily I found a free app using the Linear Accelerometer. I have found a discrepancy between the Linear and normal accelerometers in that the normal accelerometer returns readings up to 2G (and this is confirmed with a call of the getMaxRange() function). However, the linear accelerometer returns readings up to 3G - despite its getMaxRange() function returning 2G. I'm very confused. If it helps, I saw all of this on a Samsung Galaxy S2.Egon
3G is reasonable, just think about it. The maximum you can measure is 2G and after removing gravity (1G) you can get 3G indeed in some situations, depending on the orientation. In other words: acceleration = gravity + linear-acceleration and don't forget that these are vectors with signs! There length can, indeed be the way you write it.Sarcocarp
L
14

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

Lebar answered 25/7, 2013 at 16:48 Comment(2)
Nice answer, but currently all the github links are broken.Illbehaved
Consolidating projects recently. Updated. :)Lebar

© 2022 - 2024 — McMap. All rights reserved.