Sensors – Part I SE 395/595.

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 4 Overview Overview of Sensors Programming Tutorial 1: Tracking location with GPS and Google.
Advertisements

Programming with Android: System Services Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Threads, Surface Views and Real-Time Games. Background Most of the Android apps we’ve covered so far have been single threaded – And Event driven – An.
Mobile Handset Sensors. Outline Overview GPS Other Sensors 2.
Analog and digital data Skills: none IT concepts: analog to digital conversion, digital to analog conversion, sample rate, sample size, quality-file size.
Unit 4 Sensors and Actuators
Electrical and Computer Engineering SMART GOGGLES To Chong Ryan Offir Matt Ferrante James Kestyn Advisor: Dr. Tilman Wolf Preliminary Design Review.
Sensors.  Hardware devices that take measurements of the physical environment  Some examples  3-axis Accelerometer  3-axis Magnetic field sensor 
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
Real-Time Sensing on Android Reliable Mobile Systems Group Fiji Systems Inc. Yin Yan, Shaun Cosgrove, Ethan Blanton, Steven Y. Ko, Lukasz Ziarek
Introduction to Smartphone Sensors
Android sensors.
The Accelerometer and Gyroscope
CS378 - Mobile Computing Sensing and Sensors. Sensors "I should have paid more attention in Physics 41" Most devices have built in sensors to measure.
CS378 - Mobile Computing Sensing and Sensors. Sensors "I should have paid more attention in Physics 41" Most devices have built in sensors to measure.
Phone guide for people over 65. Not Smart Phones.
Android Sensors & Async Callbacks Jules White Bradley Dept. of Electrical and Computer Engineering Virginia Tech
Introduction to Mobile Sensing with Smartphones Uichin Lee April 22, 2013.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
Getting Started with Android APIs Ivan Wong. Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are.
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
Mobile Application Development Selected Topics – CPIT 490
Lecture # 9 Hardware Sensor. Topics 2  SensorManger & Sensor  SensorEvent & SensorEventListener  Example Application.
Mobile Programming Lecture 9 Bound Service, Location, Sensors, IntentFilter.
1 Localization and Sensing Nilanjan Banerjee Mobile Systems Programming (Acknowledgement: Jules White) University of Arkansas Fayetteville, AR
Sensing. Possible sensors on devices – Documented in SensorEvent class Accelerometer (m/s 2 ) – acceleration in x, y, z axes Magnetic Field (micro Tesla)
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
App Inventor You are going to use App Inventor to make an application for your phone Smart Phone ‘s can hold many entertaining apps due to the amount of.
Doodlz App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
DImpack By Chau Ngo EEL 6788 Spring Outline Problem Statement/Motivation Software Overview Demo Technical Difficulties Lessons Learned Improvements.
CS378 - Mobile Computing Sensing and Sensors Part 2.
Mobile Device Development Camera and Sensors Dr.YingLiang Ma.
Sensors in android. App being more applicable Keeping track of your heart beat while jogging. Pointing the phone camera towards the night sky to know.
Sensors Nasrullah Khan Niazi. Using Device Sensors The Android SDK provides access to raw data from sensors on the device.The sensors,and their precision.
Sensors For Mobile Phones  Ambient Light Sensor  Proximity Sensor  GPS Receiver Sensor  Gyroscope Sensor  Barometer Sensor  Accelerometer Sensor.
Arrays Chapter 7. MIS Object Oriented Systems Arrays UTD, SOM 2 Objectives Nature and purpose of an array Using arrays in Java programs Methods.
App Inventor You are going to use App Inventor to make an application for your phone Smart Phone ‘s can hold many entertaining apps due to the amount of.
CS378 - Mobile Computing Sensing and Sensors Part 2.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors Date: Feb 11, 2016.
App Inventor You are going to use App Inventor to make an application for your phone Smart Phone ‘s can hold many entertaining apps due to the amount of.
CPE 490/590 – Smartphone Development
CHAPTER 8 Sensors and Camera. Chapter objectives: Understand Motion Sensors, Environmental Sensors and Positional Sensors Learn how to acquire measurement.
User Interaction Radan Ganchev Astea Solutions. Content Basic input events Gestures Drag and drop Sensors.
Chapter 8 Sensors and Camera. Figure 08.01: The Accelerometer can gauge the orientation of a stationary device.
Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, WEB:
CS371m - Mobile Computing Sensing and Sensors.
The Doodlz app enables you to paint by dragging one or more fingers across the screen. The app provides options for setting the drawing color.
Android Android Sensors Android Sensors: – Accelerometer – Gravity sensor – Linear Acceleration sensor – Magnetic Field sensor – Orientation.
Sensors in Android.
Vijay Kumar Kolagani Dr. Yingcai Xiao
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
What's Happening Today Working with Images
Sensors, maps and fragments:
Goal : Develop a software that converts arm movements into messages
Vijay Kumar Kolagani Dr. Yingcai Xiao
CS499 – Mobile Application Development
Mobile Handset Sensors
CS371m - Mobile Computing Sensing and Sensors.
Vijay Kumar Kolagani Dr. Yingcai Xiao
Android Topics Sensors Accelerometer and the Coordinate System
Android Programming Tutorial
CIS 493/EEC 492 Android Sensor Programming
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
Android Intents & Sensors
Mobile Programming Sensors in Android.
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Sensors – Part I SE 395/595

Topics Overview of Android sensor types Overview of Sensors Framework Sensor class SensorManager class SensorEvent class SensorEventListener class Supported Sensor Types Basic elements of sensor utilization Accelerometer Example

Android Sensors Motion Position Environmental Rotation Acceleration Orientation Location Environmental Ambient Temperature Barometric pressure Light intensity Humidity

Android Sensors Framework Three main classes to work with: SensorManager class Request access to sensors Assign sensor event listeners Sensor class Encapsulates details of a particular sensor instance SensorEvent Encapsulation of new sensor data (data, type, accuracy, timestamp) SensorEventListener Responds to changes in value or accuracy for a sensor

Sensor.TYPE_<Sensor Type> List at: http://developer.android.com/reference/android/hardware/Sensor.html ACCELEROMETER (1) AMBIENT_TEMEPRATURE (13) GRAVITY (9) GYROSCOPE (4) LIGHT (5) LINEAR_ACCELERATION (10) MAGNETIC_FIELD (2) ORIENATION (deprecated) PRESSURE (6) PROXIMITY (8) RELATIVE_HUMIDITY (12) ROTATION_VECTOR (11) TEMPERATURE (deprecated)

Sensor Manager Class Must request the service in your application’s onCreate method //Get Sensor Manager Instance _sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

Sensor Class Methods Identification Methods: Performance Methods: getName() – name of the snesor getType() - what category of component is it? getVendor() – Who makes it? getVersion() – Which version of this component are we working with? Performance Methods: getPower() – “power” in mA draw getResolution() – resolution of the sensor’s measurements getMaximumRange() – maximum getMinimumDelay() – minimum time interval for updates Non-zero - streaming at the specified interval Zero – Reports only when changed Get it all!!! toString()

Sensor Manager Class: Obtain List of All Sensors public void printAllSensors() { List<Sensor> sensors = _sensorManager.getSensorList(Sensor.TYPE_ALL); for (Sensor s :sensors) { Log.i("SensorDetails", s.toString()); }

Sample Output 09-15 06:59:17.310: I/SensorDetails(28379): {Sensor name="MPL Gyroscope", vendor="Invensense", version=1, type=4, maxRange=34.90656, resolution=0.0010652636, power=5.5, minDelay=1000} 09-15 06:59:17.310: I/SensorDetails(28379): {Sensor name="MPL Raw Gyroscope", vendor="Invensense", version=1, type=16, maxRange=34.90656, resolution=0.0010652636, power=5.5, minDelay=1000} 09-15 06:59:17.310: I/SensorDetails(28379): {Sensor name="MPL Accelerometer", vendor="Invensense", version=1, type=1, maxRange=19.6133, resolution=0.039226603, power=5.5, minDelay=1000} 09-15 06:59:17.310: I/SensorDetails(28379): {Sensor name="MPL Magnetic Field", vendor="Invensense", version=1, type=2, maxRange=5461.0, resolution=0.9, power=0.15, minDelay=10000} 09-15 06:59:17.310: I/SensorDetails(28379): {Sensor name="MPL Raw Magnetic Field", vendor="Invensense", version=1, type=14, maxRange=5461.0, resolution=0.9, power=0.15, minDelay=10000} 09-15 06:59:17.310: I/SensorDetails(28379): {Sensor name="MPL Orientation", vendor="Invensense", version=1, type=3, maxRange=360.0, resolution=1.0E-5, power=11.15, minDelay=5000} 09-15 06:59:17.310: I/SensorDetails(28379): {Sensor name="MPL Rotation Vector", vendor="Invensense", version=1, type=11, maxRange=1.0, resolution=1.0E-5, power=11.15, minDelay=5000}

SensorEventListener Class Activity may implement the listener interface Class inherits interface Class creates an instance of an object that implements the listener interface Two methods must be implemented public void onAccuracyChanged(Sensor sensor, int accuracy) public void onSensorChaged(SensorEvent event)

Sensor Event Class sensor – instance of Sensor class for sensor that generated the data values – array stores raw values from the sensor e.g. If type is TYPE_ACCELEROMETER event.values[0] – acceleration along x-axis event.values[1] – acceleration along y-axis event.values[2] – acceleration along z-axis accuracy – flag for sensor accuracy SensorManger.SENSOR_STATUS_ACCURACY_LOW timestamp – time of event in nanoseconds

Android Coordinate System Source: http://developer.android.com/reference/android/hardware/SensorEvent.html#accuracy

Accelerometer Example Let’s write a simple app Displays x, y, and z axes accelerations in m/s^2 Layout Appropriate text fields Class Implement SensorEventListener Create stubs for its methods onCreate – create a sensor manager instance for accelerometer onResume – register this class as listener for accelerometer onPause – pause unregister onSensorChanged Set text views from layout to the accelerometer values: values[0], values[1], and values[2]

Accelerometer Application Demo Demonstration of the accelerometer class

References Android.com, “Sensors Overview | Android Developers”, 2013. Android.com. SensorEvent Reference. http://developer.android.com/reference/android/hardware/SensorEvent.html#accuracy, 2013.