• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps http://stackoverflow.com/questions/9013249/meaning-of-sensor-type-gravity-in-android

polonskyg

Lurker
I'm trying to figure out what the meaning of the output from gravity sensors means in Android.

I understand is the gravity applied in X, Y and Z, what I don't understand is the difference with accelerometer sensor.

I know gravity is a fuse sensor which uses gyroscope as well and others...but getting for example a value of 29.4 (9.8 * 3) in the gravity[0] sensor means that there is a force of 3G applied in the X axle?

So it would similar to use acceleration = SQRT(X^2 + Y^2 + Z^2) but more precise?

Thanks in advance! Guillermo.
 
I don't think it uses the gyroscope. In the stock gingerbread source it looks like the gravity sensor is just a low pass filter of the accelerometer data. If the device is at rest the gravity and accelerometer sensors should give identical data.
 
I don't think it uses the gyroscope. In the stock gingerbread source it looks like the gravity sensor is just a low pass filter of the accelerometer data. If the device is at rest the gravity and accelerometer sensors should give identical data.

Can you please specify in which file have you seen this? I tried searching for it in here: GrepCode: android.hardware.Sensor (.java) - Class - Source Code View and other files there, but didn't find it.

Thanks! Guillermo.
 
I have the source checked out of android.googlesource.com. Its actually implemented in 'C', not java:


frameworks/base/services/sensorservice/GravitySensor.h
frameworks/base/services/sensorservice/GravitySensor.cpp

and

frameworks/base/services/sensorservice/SecondOrderLowPassFilter.h
frameworks/base/services/sensorservice/SecondOrderLowPassFilter.cpp

This looks like an online version :

services/sensorservice/GravitySensor.cpp - frameworks-base in rowboat - Gitorious

there's probably others if you search for those filenames on google, but I recommend getting your own copy of the source tree if you're into this sort of stuff, there's instructions here:

Downloading the Source Tree | Android Open Source

it takes a while but its worth it.
 
Back
Top Bottom