SENSORS AND LOCATION BASED SERVICES ChinmayVS @ B.A.(U).G 14 JAN 2012
May 19, 2015
SENSORS AND
LOCATION BASED SERVICES
ChinmayVS @ B.A.(U).G
14 JAN 2012
Sensors & location based services
• Compass- Bearing
• Gyroscope, Accelerometer- Detect motion.
• Barometer- Calculate Altitude.
• nGPShttp://goo.gl/RWEKL (Experimental.)
2SENSORS AND LOCATION BASED SERVICES
3SENSORS AND LOCATION BASED SERVICES
cvs@BA(U)G$ who am i
• Android >2yrs. Remember anyone?
• - sensors development. 10million+ units sold.
• Presently working @
PathPartnerTech.com
“Sense-ors” on Android
1. ACCELEROMETER
2. GYROSCOPE
3. MAGNETIC_FIELD
4. LIGHT
5. PRESSURE
6. AMBIENT_TEMP
7. RELATIVE_HUMIDITY
8. PROXIMITY
9. LINEAR_ACCELERATION
10. GRAVITY
11. ROTATION_VECTOR
12. TEMPERATURE
13. ORIENTATION
Sensors and location based services 4
REAL
DEPRECEATED
A sensor (also called detector) is a device that measuresa physical quantity and converts it into a signal which can be read by
an observer or by an instrument.
VIRTUAL
“Sense-ors” on Android
1. ACCELEROMETER
2. GRAVITY
3. LINEAR_ACCELERATION
4. GYROSCOPE
5. MAGNETIC FIELD
6. ORIENTATION
7. PROXIMITY
8. ROTATION VECTOR
9. LIGHT
10. BAROMETER
11. AMBIENT TEMPERATURE
12. RELATIVE HUMIDITY
13. TEMPERATURE
Sensors and location based services 5
MOTION
A sensor (also called detector) is a device that measuresa physical quantity and converts it into a signal which can be read by
an observer or by an instrument.
POSITION
ENVIRONMENT
Sensors in Android applications
• Use-cases of sensors in apps:1. Active-Input
2. Passive-Input
3. Active-Passive
4. Auto-Rotate
Sensors and location based services 6
Application developer
Android window manager
Sensors in Android applications (1/4)
Sensors and location based services 7
• Active input
Sensors in Android applications (2/4)
• Passive input
Sensors and location based services 8
Sensors in Android applications (3/4)
• Active-passive
Sensors and location based services 9
Sensors in Android applications (4/4)
• Auto-rotate
Sensors and location based services 10
Compass : Bearing (Azimuth)
Sensors and location based services 11
90o
180o
Compass : Bearing
Sensors and location based services 12
• iPad as in-flight navigator. Android?
• Magnetic north != Geographic North
• WiFi / Network provider + Compass = GPS?
POSITION (LAT, LONG) + BEARING
Compass : Magnetic Declination
Sensors and location based services 13
Accelerometer, Gyroscope : Motion
• |Accelerometer| != 9.8 Motion
• Initial bearing + rotation of device,
POSITION (LAT, LONG) + BEARING + SPEED
Sensors and location based services 14
• 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
Barometer : Altitude
nGPS : World Geomagnetic model
Sensors and location based services 16
Using Sensors in your app
Sensors and location based services 17
http://goo.gl/hWOQuSensorEvent
http://goo.gl/1DRUvSensorManager
http://goo.gl/AVBDV
http://goo.gl/eKq6a
Examples :
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.javaAndroid/frameworks/base/core/java/android/view/WindowOrientationListener.java
When to register/unregister SensorEventListener
When to acquire/release Wakelocks
Sensors and location based services 18
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
App-dev Tips and tricks
Sensors and location based services 20
register sensorEventListener
unregister sensorEventListener
acquire wakelock
release wakelock
Thank You!!
Questions?
Sensors and location based services 21
CONTACT ME
android-porting android-developers
android-kernel android-platform