e0-245: aspdipanjan/e0_245/e0245-asp... · 2015. 3. 26. · gyroscope f=-2m Ω x v mems capacitive...

45
E0-245: ASP Lecture 16+17: Physical Sensors Dipanjan Gope

Upload: others

Post on 31-Jul-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

E0-245: ASP

Lecture 16+17: Physical Sensors

Dipanjan Gope

Page 2: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

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

Page 3: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

3

Dipanjan Gope

Activity

Views

Intent

ContentProvider

BroadcastReceiver

Service

Coverage

Page 4: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

4

Dipanjan Gope

• Greg Milette, Adam Stroud: Professional Android Sensor Programing, 2012, Wiley India

References

Page 5: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

5

Dipanjan Gope

Popular Apps with Physical Sensors

MAGNETOMETER APPS

GYROSCOPE GAMING ACCELEROMETER FITNESS

Page 6: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

6

Dipanjan Gope

Classification based on source of data

Page 7: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

7

Dipanjan Gope

Raw Sensor Data

http://developer.android.com/guide/topics/sensors/sensors_overview.html

Page 8: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

8

Dipanjan Gope

Raw Sensor Data

http://developer.android.com/guide/topics/sensors/sensors_overview.html

Page 9: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

9

Dipanjan Gope

Synthetic Sensor Data

http://developer.android.com/guide/topics/sensors/sensors_overview.html

Page 10: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

10

Dipanjan Gope

Classification based on application

Page 11: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

11

Dipanjan Gope

• Motion - Accelerometer

- Gyroscope

- Linear acceleration

- Gravity

• Position - Magnetic field

- Proximity

- Rotation vector

• Environment - Light

- Barometer

- Ambient temperature

- Relative humidity

Physical Sensors

Page 12: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

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

Page 13: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

13

Dipanjan Gope

Sensor Hardware

Page 14: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

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

Page 15: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

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

Page 16: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

16

Dipanjan Gope

Magnetic Field

Anonymous, 400BC

http://en.wikipedia.org/wiki/Hall_effect

Lorentz Force

Asahi Kasei: AK8975C Others: Anisotropic Magneto Resistance

Page 17: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

17

Dipanjan Gope

Android Sensor Data Structures

Page 18: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

18

Dipanjan Gope

Class:

• SensorManager

• Sensor

• SensorEvent

Interface:

• SensorEventListener

Android.hardware

Page 19: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

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

Page 20: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

20

Dipanjan Gope

Package: Android.hardware

SensorManager

Sensor SensorEventListener

SensorEvent

Produces Consumed

Specifies

Event Values

Page 21: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

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

Page 22: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

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

Page 23: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

23

Dipanjan Gope

• private SensorManager sensorManager;

• sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

• List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_****);

• Sensor = sensorManager.getDefaultSensor(Sensor.TYPE_***);

SensorManager

Page 24: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

24

Dipanjan Gope

• Maximum range

• Minimum delay

• Name

• Power

• Resolution

• Type

• Vendor

• Version

Sensor Class

Page 25: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

25

Dipanjan Gope

• Accuracy - SENSOR_STATUS_ACCURACY_HIGH

- SENSOR_STATUS_ACCURACY_MEDIUM

- SENSOR_STATUS_ACCURACY_LOW

- SENSOR_STATUS_ACCURACY_UNRELIABLE

• Sensor

• Timestamp

• Values

SensorEvent

Page 26: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

26

Dipanjan Gope

• onAccuracyChanged

- when the accuracy from the sensor changes

• onSensorChanged

- when the values from the sensor changes

SensorEventListener

Page 27: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

27

Dipanjan Gope

Sensor Data Reference

http://developer.android.com/guide/topics/sensors/sensors_overview.html

Page 28: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

28

Dipanjan Gope

Lets Code …

Page 29: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

29

Dipanjan Gope

1. Determine Available Sensors

Page 30: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

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

Page 31: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

31

Dipanjan Gope

Implicit Intent

http://developer.android.com/guide/components/intents-filters.html

Page 32: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

32

Dipanjan Gope

• Primitive

Passing Data: Extras

Page 33: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

33

Dipanjan Gope

• Persistent Objects

Passing Data: Application

Page 34: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

34

Dipanjan Gope

2. Determine Sensor Range and Resolution

Page 35: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

35

Dipanjan Gope

• Acceleration: m/s2

• Gyroscope: Deg/s or Rad/s

• Magnetic Field: uT

• Min Delay: us

• Power: mA

Units

Page 36: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

36

Dipanjan Gope

• SENSOR_DELAY_FASTEST 0ms

• SENSOR_DELAY_GAME 20ms

• SENSOR_DELAY_UI 67ms

• SENSOR_DELAY_NORMAL 200ms

3. Define Sensor Rate

Page 37: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

37

Dipanjan Gope

Sensor Results Display

Page 38: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

38

Dipanjan Gope

4. Register/Unregister SensorListeners

Page 39: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

39

Dipanjan Gope

Signal Processing and Sensor Fusion

Page 40: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

40

Dipanjan Gope

Accuracy and Precision

Greg Milette, Adam Stroud: Professional Android Sensor Programing, 2012, Wiley India

Page 41: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

41

Dipanjan Gope

• Noise

• Drift

Type of Error

Accelerometer Drift

Paul Lawitski, Sensor fusion

Gyroscope Drift

Page 42: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

42

Dipanjan Gope

• Low-pass filter

Filtering

• High-pass filter to filter noise in gravity

• Kalman filter

- systems dynamic model and constraints

Page 43: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

43

Dipanjan Gope

Sensor Fusion

Page 44: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

44

Dipanjan Gope

Acceleration in Earth’s axis

Page 45: E0-245: ASPdipanjan/E0_245/E0245-ASP... · 2015. 3. 26. · Gyroscope F=-2m Ω x v MEMS Capacitive based SIP Ref: MEMS gyroscopes - A revolutionary way to interface with the real

45

Dipanjan Gope

Activity

Views

Intent

ContentProvider

BroadcastReceiver

Service

Coverage