e0-245: aspdipanjan/e0_245/e0245-asp... · 2015. 3. 26. · gyroscope f=-2m Ω x v mems capacitive...
TRANSCRIPT
E0-245: ASP
Lecture 16+17: Physical Sensors
Dipanjan Gope
2
Dipanjan Gope
• Location Sensors - Theory of location sensing
- Package android.location
• Physical Sensors - Sensor Manager
- Accelerometer
- Gyroscope
- Magnetometer
- Sensor fusion
• Multimedia - Camera
- Microphone
• NFC
Module 2: Android Sensor Applications
3
Dipanjan Gope
Activity
Views
Intent
ContentProvider
BroadcastReceiver
Service
Coverage
4
Dipanjan Gope
• Greg Milette, Adam Stroud: Professional Android Sensor Programing, 2012, Wiley India
References
5
Dipanjan Gope
Popular Apps with Physical Sensors
MAGNETOMETER APPS
GYROSCOPE GAMING ACCELEROMETER FITNESS
6
Dipanjan Gope
Classification based on source of data
7
Dipanjan Gope
Raw Sensor Data
http://developer.android.com/guide/topics/sensors/sensors_overview.html
8
Dipanjan Gope
Raw Sensor Data
http://developer.android.com/guide/topics/sensors/sensors_overview.html
9
Dipanjan Gope
Synthetic Sensor Data
http://developer.android.com/guide/topics/sensors/sensors_overview.html
10
Dipanjan Gope
Classification based on application
11
Dipanjan Gope
• Motion - Accelerometer
- Gyroscope
- Linear acceleration
- Gravity
• Position - Magnetic field
- Proximity
- Rotation vector
• Environment - Light
- Barometer
- Ambient temperature
- Relative humidity
Physical Sensors
12
Dipanjan Gope
Smart Watches Today
https://www.google.co.in/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0CAcQjRw&url=http%3A%2F%2Fwww.slideshare.net%2FLeybzon%2Fapple-iwatch-android-wear-and-other-wristbased-sensor-platforms&ei=J-EQVe6sDNWdugS84oGwBg&psig=AFQjCNFwN3VY9DQjg7lYqPiWdZqxh0qR8A&ust=1427255772724923
13
Dipanjan Gope
Sensor Hardware
14
Dipanjan Gope
Accelerometer
F=mA MEMS Capacitive-based SIP
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00037200.pdf
https://www.youtube.com/watch?v=i2U49usFo10
15
Dipanjan Gope
Gyroscope
F=-2m Ω x v MEMS Capacitive based SIP
Ref: MEMS gyroscopes - A revolutionary way to interface with the real world, STMicroelectronics
16
Dipanjan Gope
Magnetic Field
Anonymous, 400BC
http://en.wikipedia.org/wiki/Hall_effect
Lorentz Force
Asahi Kasei: AK8975C Others: Anisotropic Magneto Resistance
17
Dipanjan Gope
Android Sensor Data Structures
18
Dipanjan Gope
Class:
• SensorManager
• Sensor
• SensorEvent
Interface:
• SensorEventListener
Android.hardware
19
Dipanjan Gope
Package: Android.location
LocationManager
LocationProvider LocationListener
Location
Criteria
Enables Notifies with location data
Produces Consumed
Reads LocationProvider Requirements
Greg Milette, Adam Stroud: Professional Android Sensor Programing, 2012, Wiley India
20
Dipanjan Gope
Package: Android.hardware
SensorManager
Sensor SensorEventListener
SensorEvent
Produces Consumed
Specifies
Event Values
21
Dipanjan Gope
<uses-feature android:name="android.hardware.sensor.accelerometer"
android:required="true" />
<uses-feature android:name="android.hardware.sensor.compass"
android:required="false" />
Manifest File
22
Dipanjan Gope
• android.hardware.sensor.accelerometer
• android.hardware.sensor.gyroscope
• android.hardware.sensor.compass
• android.hardware.sensor.barometer
• android.hardware.sensor.light
• android.hardware.sensor.proximity
Manifest File
23
Dipanjan Gope
• private SensorManager sensorManager;
• sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
• List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_****);
• Sensor = sensorManager.getDefaultSensor(Sensor.TYPE_***);
SensorManager
24
Dipanjan Gope
• Maximum range
• Minimum delay
• Name
• Power
• Resolution
• Type
• Vendor
• Version
Sensor Class
25
Dipanjan Gope
• Accuracy - SENSOR_STATUS_ACCURACY_HIGH
- SENSOR_STATUS_ACCURACY_MEDIUM
- SENSOR_STATUS_ACCURACY_LOW
- SENSOR_STATUS_ACCURACY_UNRELIABLE
• Sensor
• Timestamp
• Values
SensorEvent
26
Dipanjan Gope
• onAccuracyChanged
- when the accuracy from the sensor changes
• onSensorChanged
- when the values from the sensor changes
SensorEventListener
27
Dipanjan Gope
Sensor Data Reference
http://developer.android.com/guide/topics/sensors/sensors_overview.html
28
Dipanjan Gope
Lets Code …
29
Dipanjan Gope
1. Determine Available Sensors
30
Dipanjan Gope
• Move from one screen (activity) to another
• Can also open other applications
• 3 main: start an activity/service/broadcast
• Asynchronous
• Bound at run-time
• Explicit or implicit
Building Block: Intent
31
Dipanjan Gope
Implicit Intent
http://developer.android.com/guide/components/intents-filters.html
32
Dipanjan Gope
• Primitive
Passing Data: Extras
33
Dipanjan Gope
• Persistent Objects
Passing Data: Application
34
Dipanjan Gope
2. Determine Sensor Range and Resolution
35
Dipanjan Gope
• Acceleration: m/s2
• Gyroscope: Deg/s or Rad/s
• Magnetic Field: uT
• Min Delay: us
• Power: mA
Units
36
Dipanjan Gope
• SENSOR_DELAY_FASTEST 0ms
• SENSOR_DELAY_GAME 20ms
• SENSOR_DELAY_UI 67ms
• SENSOR_DELAY_NORMAL 200ms
3. Define Sensor Rate
37
Dipanjan Gope
Sensor Results Display
38
Dipanjan Gope
4. Register/Unregister SensorListeners
39
Dipanjan Gope
Signal Processing and Sensor Fusion
40
Dipanjan Gope
Accuracy and Precision
Greg Milette, Adam Stroud: Professional Android Sensor Programing, 2012, Wiley India
41
Dipanjan Gope
• Noise
• Drift
Type of Error
Accelerometer Drift
Paul Lawitski, Sensor fusion
Gyroscope Drift
42
Dipanjan Gope
• Low-pass filter
Filtering
• High-pass filter to filter noise in gravity
• Kalman filter
- systems dynamic model and constraints
43
Dipanjan Gope
Sensor Fusion
44
Dipanjan Gope
Acceleration in Earth’s axis
45
Dipanjan Gope
Activity
Views
Intent
ContentProvider
BroadcastReceiver
Service
Coverage