+ All Categories
Home > Technology > Making sense

Making sense

Date post: 11-Feb-2017
Category:
Upload: jared-sheehan
View: 182 times
Download: 0 times
Share this document with a friend
50
Making Sense The Road to mobile Awareness •Jared Sheehan •Twitter: @jayroo5245 •meetup.com/DCAndroid •slideshare.net/Jayroo5245
Transcript
Page 1: Making sense

Making SenseThe Road to mobile Awareness

• Jared Sheehan• Twitter: @jayroo5245• meetup.com/DCAndroid• slideshare.net/Jayroo5245

Page 2: Making sense

• What is Contextual Awareness?

• Use Cases• Sensor Fusion• Hard way• Medium hard way• Easy way• Questions

Agenda

Page 3: Making sense

“Context is any information that can be used to characterize the situation of an entity. An entity is a person, place, or object that is considered relevant to the interaction between a user and an application, including the user and application themselves. ”

• Anind Dey• Director of Human-Computer

interaction at Carnegie Mellon University

Page 4: Making sense

• Mobile sensing of a user’s context• Sensor based algorithms • Some Sensor Types on the Android

Platform• Accelerometer• Gyroscope/Orientation/Rotation

Vector• Barometric Pressure• Magnetic Field• Gravity• Relative Humidity• Ambient Room Temperature• Device Temperature

Mobile Contextual Awareness

Page 5: Making sense

Sensor Types in Android

Page 6: Making sense

• Detecting when a user:• Changes the orientation of a

their device• walking, running or biking• Driving a vehicle• Handling their device• Driving AND Handling their

device • Disclaimer – Don’t do it

• Drives by a restaurant or coffee shop when it is open• Driving detection• Google Places• Time

Use Cases

Page 7: Making sense

Sensor fusion is combining of sensory data or data derived from disparate sources such that the resulting information has less uncertainty than would be possible when these sources were used individually.

Sensor Fusion – What is it?

Page 8: Making sense

If a developer takes individual sensor output and combines it with additional output from other sensors (or other hints) then you get a better understanding of what is going on with the mobile device.

Sensor Fusion – What is it?

Page 9: Making sense
Page 10: Making sense

Determine the attitude of a mobile device.

Attitude - orientation of a device relative to Earth's horizon

Sensor Fusion – Example

Page 11: Making sense
Page 12: Making sense

The common way to get the attitude of an Android device is to use the SensorManager.getOrientation() method to get the three orientation angles. These two angles are based on the accelerometer and magnetometer output.

Sensor Fusion – Example

Page 13: Making sense

In simple terms, the accelerometer provides the gravity vector (the vector pointing towards the center of the earth) and the magnetometer works as a compass. The Information from both sensors suffice to calculate the device’s orientation.

Sensor Fusion – Example

Page 14: Making sense

Isn’t that enough?

Sensor Fusion – Example

No

Problem is that both sensor outputs are inaccurate, especially the output from the magnetic field sensor which includes a lot of noise.

How do we fix it?

Page 15: Making sense

Gyro drift and noisy orientation are common issues with this approach, to solve it, the gyroscope output is applied only for orientation changes in short time intervals. While the magnetometer/accelerometer data is used as support information over long periods of time.

Sensor Fusion – Example

Page 16: Making sense

This is equivalent to low-pass filtering of the accelerometer and magnetic field sensor signals and high-pass filtering of the gyroscope signals. The overall sensor fusion and filtering looks like this:

Sensor Fusion – Example

Page 17: Making sense

Sensor Fusion – Example

Page 18: Making sense

So what exactly does high-pass and low-pass filtering of the sensor data mean? The sensors provide their data at (more or less) regular time intervals. Their values can be shown as signals in a graph with the time as the x-axis, similar to an audio signal.

Sensor Fusion – Example

Page 19: Making sense

The low-pass filtering of the noisy accelerometer/magnetometer signal (accMagOrientationin the above figure) are orientation angles averaged over time within a constant time window.

Sensor Fusion – Example

Page 20: Making sense

Initialize sensor containers:

Sensor Fusion – Example

Page 21: Making sense

Register you listeners:

Sensor Fusion – Example

Page 22: Making sense

Store sensor events:

Sensor Fusion – Example

Page 23: Making sense

At some time interval you process the sensor arrays and then events can be inferred from a single or multiple passes.

Sensor Fusion – Example

Page 24: Making sense

Example of Rotation Vector processing: https://developer.android.com/reference/android/hardware/SensorEvent.html#values

Sensor Fusion – Example

Page 25: Making sense

• https://github.com/Jayroo5245/makingsense

• https://github.com/Jayroo5245

Demo time!

Page 26: Making sense

• This is a simple-ish formula to obtain one feature• Very large task• Lots of math, calculations,

sensor state maintenance• Not something a standard

Android developer is used to working with

Sensor Fusion – Challenges

Page 27: Making sense

• How do you support 100% of devices?

• Very difficult• Android Fragmentation• Not all sensors return values

at the same frequency

Sensor Fusion – Challenges

Page 28: Making sense

• Process prioritization issues• OEMs build devices to

their specs, not ours• Missing sensors on some

devices.• Android/Java platform

limitations• Go Native - NDK

Sensor Fusion – Challenges

Page 29: Making sense

Example Platform limitation: The Android Platform was not designed to process sensor data as fast as it is generated. Using an Executor had the best results but you will not get consistent 16, 32 or 64 hertz.

Sensor Fusion – Challenges

Page 30: Making sense
Page 31: Making sense

• External Libraries• Lost - Drop in Replacement for

Google’s Fused Location API• www.zendrive.com• www.driversiti.com• www.pathsense.com• www.locationkit.io

Alternatives to the hard way:

Page 32: Making sense

• External Libraries• Licensing – IE Cost• Probably don’t do exactly

what you want• Inference

Change/Deprecation• lack support• Battery Drain

Drawbacks to External Libs:

Page 33: Making sense

Battery Issues:

Page 34: Making sense
Page 35: Making sense

Let Google Do It for you – Awareness API

Page 36: Making sense

• Current Local Time

Context #1– Time

Page 37: Making sense

• Latitude• Longitude

Context #2 – Location

Page 38: Making sense

• Place, including place Type

Context #3 – Place

Page 39: Making sense

• Activity Recognition• Detected user activity

(walking, running, biking)

Context #4 – Activity

Page 40: Making sense

• Nearby beacons (including namespace, type, and content)

Context #5 – Beacons

Page 41: Making sense

• Are the Headphones plugged?

Context #6 – Headphones

Page 42: Making sense

• Current Weather Conditions

Context #7 – Weather

Page 43: Making sense

• Apps can combine these context signals to make inferences about the user's current situation, and use this information to provide customized experiences.

• Exp: Suggest a playlist while jogging in the rain.

What is it?

Page 44: Making sense

• Easy implementation• One API

• Signals are processed for the app• No need to build

complicated algorithms

• Optimized Battery

Awareness Benefits

Page 45: Making sense

• Fence API• System Notifications

• Snapshot API• Real time request

Great now what?

Page 46: Making sense

• Push Mechanism - React to specific situations

• Provides notifications when a specific combination of actions occur

• Exp: Tell me when a user is biking, its lunchtime and near a bike friendly restaurant

Fence API

Page 47: Making sense

• Pull mechanism• Provides notifications

when a specific combination of actions occur

• Exp: Tell me when a user is biking, its lunchtime and near a bike friendly restaurant

Snapshot API

Page 48: Making sense

• Hard way• Build your own

• Easier Way• External Lib

• Easiest Way• Awareness API

Three options

Page 49: Making sense

Thank you for coming!The Road to mobile Awareness

• Jared Sheehan• Twitter: @jayroo5245• meetup.com/DCAndroid• slideshare.net/Jayroo5245

Page 50: Making sense

Sources• https://en.wikipedia.org/wiki/Sensor_fusion• https://developer.android.com/guide/topics/sensors/sensors_overview.html• http://plaw.info/2012/03/android-sensor-fusion-tutorial/comment-page-1/• http://

www.androidpolice.com/2016/05/19/the-new-awareness-api-will-let-apps-better-understand-your-environment/• https://developers.google.com/awareness/overview• https://

www.interaction-design.org/literature/book/the-encyclopedia-of-human-computer-interaction-2nd-ed/context-aware-computing-context-awareness-context-aware-user-interfaces-and-implicit-interaction


Recommended