Lecture # 9 Hardware Sensor. Topics 2  SensorManger & Sensor  SensorEvent & SensorEventListener  Example Application.

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.
Mobile Handset Sensors. Outline Overview GPS Other Sensors 2.
Three Dimensional Viewing
University of Bridgeport
Localizing Sounds. When we perceive a sound, we often simultaneously perceive the location of that sound. Even new born infants orient their eyes toward.
Creating Mobile Apps with App Inventor! Day 4 Google search Kris Gordon Ludlow for links.
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.
Introduction to Smartphone Sensors
Android sensors.
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.
Building Sensor-based Apps Windows Phone Windows Store Windows Desktop
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.
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
Mobile Application Development Selected Topics – CPIT 490
CSS216 MOBILE PROGRAMMING Android, Chapter 13 Book: “Professional Android™ 2 Application Development” by Reto Meier, 2010 by: Andrey Bogdanchikov (
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)
Project Objectives Today’s GPS technology allow calculating and producing accurate positioning and tracking of the movement path in open environments.
Doodlz App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
1 CMSC 628: Introduction to Mobile Computing Nilanjan Banerjee Introduction to Mobile Computing University of Maryland Baltimore County
ESP Electronic Stability Programs
Robot sensors MVRT 2010 – 2011 season. Analog versus Digital Analog Goes from 0 to 254 Numerous values Similar to making waves because there are not sudden.
Sensors – Part I SE 395/595.
CS378 - Mobile Computing Sensing and Sensors Part 2.
Location. GPS Global Positioning System – At least 4 satellites typically used 3 required extra for error detection and altitude typically accurate within.
ADCS Review – Attitude Determination Prof. Der-Ming Ma, Ph.D. Dept. of Aerospace Engineering Tamkang University.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
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.
Navigating in 3D MAX CTEC V part 1. Viewing Objects and/or Scenes Depending upon the software program, the image on the monitor could be a Perspective.
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.
CS378 - Mobile Computing Sensing and Sensors Part 2.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors Date: Feb 11, 2016.
Camera. “Up”, “Forward” and “Along” The three camera view vectors are defined as shown:
Between which two points is there a constant speed?
INTRODUCTION TO DYNAMICS ANALYSIS OF ROBOTS (Part 1)
Make an information leaflet about what the sensors do in a Smart Phone for people over 65 years of age. You can use PowerPoint, Word or Publisher.
84 Interpreting Graphs 83 10/30/15 Starter: Quiz Application Notes Glue here when done Connection : Complete Ws Exit: A plane traveled North 1500 miles.
Accelerometer based motion gestures for mobile devices Presented by – Neel Parikh Advisor Committee members Dr. Chris Pollett Dr. Robert Chun Dr. Mark.
CPE 490/590 – Smartphone Development
170 Interpreting Graphs 169 2/10/2016 Starter: What is the difference between speed and velocity? Application Notes Glue here when done Connection : Complete.
CHAPTER 8 Sensors and Camera. Chapter objectives: Understand Motion Sensors, Environmental Sensors and Positional Sensors Learn how to acquire measurement.
Chapter 8 Sensors and Camera. Figure 08.01: The Accelerometer can gauge the orientation of a stationary device.
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
Comparison of Sensor Analysis for Swimming in Different Positions
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
Sensors, maps and fragments:
Vijay Kumar Kolagani Dr. Yingcai Xiao
CS499 – Mobile Application Development
Mobile Handset Sensors
CS371m - Mobile Computing Sensing and Sensors.
CIS 470 Mobile App Development
Vijay Kumar Kolagani Dr. Yingcai Xiao
Inertial Measurement Unit (IMU) Basics
Android Topics Sensors Accelerometer and the Coordinate System
Android Programming Tutorial
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors.
Mobile Programming Sensors in Android.
Device,Network, Vibration, Console, Accelerometer
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Lecture # 9 Hardware Sensor

Topics 2  SensorManger & Sensor  SensorEvent & SensorEventListener  Example Application

Sensors 3  Hardware Devices that measure the physical environment  Motion Ex. 3-Axis Accelerometer  Position Ex. 3-Axis Magnetic Field  Environment Ex. Pressure, Light

 used to manage the sensor hardware available on Android devices.  getSystemService return a reference to the Sensor Manager Service, as shown in the following snippet: Sensor Manager String service_name = Context.SENSOR_SERVICE; SsensorManager sensorManager=(SensorManager) getSystemService(service_name); String service_name = Context.SENSOR_SERVICE; SsensorManager sensorManager=(SensorManager) getSystemService(service_name);

 Like location-based Services, Android abstracts the sensor implementations of each device  The Sensor class is used to describe the properties of each hardware sensor( type, name, manufacturer, and details on its accuracy and range).  The Sensor class includes a set of constants used to describe what type of hardware sensor is being represented by a Sensor object. Introducing Sensors

 Sensor.TYPE_ACCELEROMETER  Sensor.TYPE_GYROSCOPE  Sensor.TYPE_LIGHT  Sensor.TYPE_MAGNETIC_FIELD  Sensor.TYPE_ORIENTATION  Sensor.TYPE_PRESSURE  Sensor.TYPE_PROXIMITY  Sensor.TYPE_TEMPERATURE Supported Android Sensors

 An Android device can include multiple implementations of a particular sensor-type.  To find the default Sensor implementation for a particular type use the Sensor Manager’s getDefaultSensor method, passing in the sensor-type required from the constants  The following snippet returns the default gyroscope. If no default Sensor exists for the given type, the method returns null. Finding Sensors Sensor defaultGyroscope = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);

 Alternatively, use getSensorList to return a list of all the available Sensors of a given type, as shown in the following code, which returns all the available pressure sensor objects:  To find every Sensor available on the host platform use getSensorList, passing in Sensor.TYPE_ALL, as shown here: Finding Sensors List pressureSensors = sensorManager.getSensorList(Sensor.TYPE_PRESSURE); List allSensors = sensorManager.getSensorList(Sensor.TYPE_ALL);

Listening for Sensors  Accuracy: – SensorManager.SENSOR_STATUS_ACCURACY_LOW – SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM – SensorManager.SENSOR_STATUS_ACCURACY_HIGH – SensorManager.SENSOR_STATUS_ACCURACY_UNRELIABL

 The SensorEvent parameter in the onSensorChanged method includes four properties used to describe a Sensor event:  Sensor  Accuracy  Values  Timestamp  You can monitor changes in the accuracy of a Sensor separately, using the onAccuracyChanged method. Using Sensors

 In both handlers the accuracy value represents feedback from the monitored Sensor’s accuracy, using one of the following constants:  SensorManager.SENSOR_STATUS_ACCURACY_LOW  SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM  SensorManager.SENSOR_STATUS_ACCURACY_HIGH  SensorManager.SENSOR_STATUS_UNRELIABLE Using Sensors

 To receive Sensor events, register your Sensor Event Listener with the Sensor Manager (usually onResume).  Specify the Sensor object to observe, and the rate at which you want to receive updates  The following example registers a Sensor Event Listener for the default proximity Sensor at the normal update rate: Registering Sensors

 The Sensor Manager includes the following constants (shown in descending order of responsiveness) to let you select a suitable update rate:  SensorManager.SENSOR_DELAY_FASTEST  SensorManager.SENSOR_DELAY_GAME  SensorManager.SENSOR_DELAY_NORMAL  SensorManager.SENSOR_DELAY_UI  To minimize the associated resource cost of using the Sensor in your application you should try to select the slowest suitable rate. Registering Sensors

 It’s also important to unregister your Sensor Event Listeners when your application no longer needs to receive updates: sensorManager.unregisterListener(mySensorEventListener, sensor);  It’s good practice to register and unregister your Sensor Event Listener in the onResume and onPause methods of your Activities to ensure they’re being used only when the Activity is active Registering Sensors

 The length and composition of the values returned in the onSensorChanged event vary depending on the Sensor being monitored. INTERPRETING SENSOR VALUES

 Accelerometers used to measure acceleration also referred to as gravity sensors.  accelerometers measure how quickly the speed of the device is changing in a given direction.  Using an accelerometer you can detect movement and, more usefully, the rate of change of the speed of that movement Accelerometers

 Acceleration can be measured along three directional axes: left-right(lateral), forward-backward (longitudinal), and up- down(vertical).  The Sensor Manager reports accelerometer Sensorchanges along all three axes.  The values passed in through the values property of the Sensor Event Listener’s Sensor Event parameter represent lateral,longitudinal, and vertical acceleration, in that order. Detecting Acceleration Changes

 The Sensor Manager considers the device ‘‘at rest’’ when it is sitting face up on a flat surface in portrait orientation.  x-axis (lateral)  y-axis (longitudinal)  z-axis (vertical) Detecting Acceleration Changes

 you monitor changes in acceleration using a Sensor Event Listener  Register an implementation of SensorEventListener with the Sensor Manager, using a Sensor object of type Sensor.TYPE_ACCELEROMETER to request accelerometer updates Detecting Acceleration Changes

Example1: Displaying Accelerometer and Orientation Data 21

Example1(Continue…) 22

Example1(Continue…) 23

Example1(Continue…) 24

Example2: 25

26

Listener for Changes (Accel)

Accelerometer 29

Sensor Orientation 30

31  Introduction to sensor orientation  This example shows how to capture the orientation of the mobile device. We define the orientation as a combination of three angular quantities: Azimuth, pitch, and roll. The three quantities are defined based on the axes as shown in following image:  As you can see, the positive X-axis extends out of the right side of the phone, positive Y-axis extends out of the top side, and the positive Z-axis extends out of the front face of the phone. This is independent of the orientation of the phone.  Definition of Azimuth, Pitch, and Roll  Azimuth is angle between the positive Y-axis and magnetic north and its range is between 0 and 360 degrees.  Positive Roll is defined when the phone starts by laying flat on a table and the positive Z-axis begins to tilt towards the positive X-axis.  Positive Pitch is defined when the phone starts by laying flat on a table and the positive Z-axis begins to tilt towards the positive Y-axis.