Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development > Developer 101

Developer 101 101 Tutorials



Reply
 
LinkBack Thread Tools
Old February 2nd, 2012, 06:23 AM   #1 (permalink)
New Member
 
Join Date: Aug 2010
Posts: 8
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Default http://stackoverflow.com/questions/9013249/meaning-of-sensor-type-gravity-in-android

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.

polonskyg is offline  
Reply With Quote
Sponsors
Old February 8th, 2012, 04:10 PM   #2 (permalink)
Member
 
Snedd's Avatar
 
Join Date: Oct 2010
Location: UK
Posts: 172
 
Device(s): Nexus S, Disgo Tablet
Thanks: 17
Thanked 46 Times in 37 Posts
Default

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.
Snedd is offline  
Reply With Quote
Old February 8th, 2012, 08:22 PM   #3 (permalink)
New Member
 
Join Date: Aug 2010
Posts: 8
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Snedd View Post
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.
polonskyg is offline  
Reply With Quote
Old February 9th, 2012, 01:18 AM   #4 (permalink)
Member
 
Snedd's Avatar
 
Join Date: Oct 2010
Location: UK
Posts: 172
 
Device(s): Nexus S, Disgo Tablet
Thanks: 17
Thanked 46 Times in 37 Posts
Default

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.
Snedd is offline  
Last edited by Snedd; February 9th, 2012 at 01:27 AM.
Reply With Quote
The Following User Says Thank You to Snedd For This Useful Post:
polonskyg (February 9th, 2012)
Reply

Bookmarks

Tags
android, gravity, sensors, type_gravity


Go Back   Android Forums > Android Development > Application Development > Developer 101 User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 08:26 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo