This document discusses sensors and location-based services on Android devices. It describes several types of sensors including compass, gyroscope, accelerometer, barometer, and GPS. It provides examples of how these sensors can be used in applications for active input, passive input, active-passive functions, and auto-rotate capabilities. The document also offers tips for sensor calibration, polling rates, sensor fusion, and managing sensor event listeners and wake locks in apps.
3. cvs@BA(U)G$ who am i
• Android >2yrs. Remember anyone?
• - sensors development. 10million+ units sold.
• Presently working @
PathPartnerTech.com
SENSORS AND LOCATION BASED SERVICES 3
4. “Sense-ors” on Android
A sensor (also called detector) is a device that measures
a physical quantity and converts it into a signal which can be read by
an observer or by an instrument.
1. ACCELEROMETER
2. GYROSCOPE
3. MAGNETIC_FIELD
REAL
4. LIGHT
5. PRESSURE
6. AMBIENT_TEMP
7. RELATIVE_HUMIDITY
8. PROXIMITY
VIRTUAL 9. LINEAR_ACCELERATION
10. GRAVITY
11. ROTATION_VECTOR
DEPRECEATED
12. TEMPERATURE
13. ORIENTATION
Sensors and location based services 4
5. “Sense-ors” on Android
A sensor (also called detector) is a device that measures
a physical quantity and converts it into a signal which can be read by
an observer or by an instrument.
1. ACCELEROMETER
2. GRAVITY
MOTION
3. LINEAR_ACCELERATION
4. GYROSCOPE
5. MAGNETIC FIELD
POSITION 6. ORIENTATION
7. PROXIMITY
8. ROTATION VECTOR
9. LIGHT
10. BAROMETER
ENVIRONMENT 11. AMBIENT TEMPERATURE
12. RELATIVE HUMIDITY
13. TEMPERATURE
Sensors and location based services 5
6. Sensors in Android applications
• Use-cases of sensors in apps:
1. Active-Input
2. Passive-Input Application developer
3. Active-Passive
4. Auto-Rotate Android window manager
Sensors and location based services 6
7. Sensors in Android applications (1/4)
• Active input
Sensors and location based services 7
8. Sensors in Android applications (2/4)
• Passive input
Sensors and location based services 8
9. Sensors in Android applications (3/4)
• Active-passive
Sensors and location based services 9
10. Sensors in Android applications (4/4)
• Auto-rotate
Sensors and location based services 10
11. Compass : Bearing (Azimuth)
90o
180o
Sensors and location based services 11
12. Compass : Bearing
• iPad as in-flight navigator. Android?
• Magnetic north != Geographic North
• WiFi / Network provider + Compass = GPS?
POSITION (LAT, LONG) + BEARING
Sensors and location based services 12
14. Accelerometer, Gyroscope : Motion
• |Accelerometer| != 9.8 Motion
• Initial bearing + rotation of device,
POSITION (LAT, LONG) + BEARING + SPEED
Sensors and location based services 14
15. Barometer : Altitude
• Remember this ?
“ WiFi / Network provider + Compass = GPS”
now how about,
“ WiFi / Network provider + Compass + Barometer ”
POSITION (LAT, LONG) + BEARING + SPEED + ALTITUDE > GPS
Sensors and location based services 15
16. nGPS : World Geomagnetic model
Sensors and location based services 16
17. Using Sensors in your app
SensorEvent http://goo.gl/hWOQu
SensorManager http://goo.gl/1DRUv
Examples :
http://goo.gl/AVBDV
http://goo.gl/eKq6a
Sensors and location based services 17
18. Sensor app-dev Tips and tricks
Sensor calibration.
1. one-turn deserves another (axes-calib)
2. zero-calib
Polling rate fastest/game/ui/normal?
Sensor fusion
Hard-way
Easy-way (Invensense ) http://goo.gl/bHmDe
Lessons from WindowOrientationListener.java
Android/frameworks/base/core/java/android/view/WindowOrientationListener.java
When to register/unregister SensorEventListener
When to acquire/release Wakelocks
Sensors and location based services 18
19. WindowOrientationListener.java
Low-pass filter the tilt and orientation angles to avoid "twitchy" behaviour.
When the orientation angle reaches a certain threshold, transition
These thresholds have some hysteresis built-in to avoid oscillation.
Use the magnitude to judge the accuracy of the data.
Under ideal conditions, the magnitude should equal to that of gravity.
When it differs significantly, we know the device is under external acceleration
Use the tilt angle to judge the accuracy of orientation data.
When the tilt angle is high in magnitude, we distrust the orientation data.
When the device is flat, small physical motion = large changes in orientation angle.
Sensors and location based services 19
20. App-dev Tips and tricks
register
sensorEventListener
acquire wakelock
release wakelock
unregister
sensorEventListener
Sensors and location based services 20
21. Thank You!!
Questions?
android-porting android-developers
android-kernel android-platform
CONTACT ME
Sensors and location based services 21