Android Sensors 101. 2014 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. CC-BY Google

Similar documents
Inside Android's UI Embedded Linux Conference Europe 2012 Karim

Android Architecture. Alexandra Harrison & Jake Saxton

Android Operating System:

Designing An Android Sensor Subsystem Pitfalls and Considerations

01. Introduction of Android

Using the Adafruit Unified Sensor Driver. Created by Kevin Townsend

Sensor Fusion Mobile Platform Challenges and Future Directions Jim Steele VP of Engineering, Sensor Platforms, Inc.

Android Architecture For Beginners

Research and Design of Universal and Open Software Development Platform for Digital Home

Android Sensors. XI Jornadas SLCENT de Actualización Informática y Electrónica

HP TouchPad Sensor Setup for Android

Android Concepts and Programming TUTORIAL 1

Android Programming and Security

Mobile Devices - An Introduction to the Android Operating Environment. Design, Architecture, and Performance Implications

Programming the Android Platform. Logistics

What else can you do with Android? Inside Android. Chris Simmonds. Embedded Linux Conference Europe Copyright 2010, 2net Limited.

Using Chroot to Bring Linux Applications to Android

Mobile Devices - An Introduction to the Android Operating Environment. Design, Architecture, and Performance Implications

A Look through the Android Stack

Android Operating System

Objective. Android Sensors. Sensor Manager Sensor Types Examples. Page 2

Extending Android's Platform Toolsuite

Android Development Exercises Version Hands On Exercises for. Android Development. v

ANDROID OPERATING SYSTEM

GETTING STARTED WITH ANDROID DEVELOPMENT FOR EMBEDDED SYSTEMS

Developing for MSI Android Devices

Dynamic Android Sensor HAL

Mobile Phones Operating Systems

AN4156 Application note

How To Develop Android On Your Computer Or Tablet Or Phone

CSE476 Mobile Application Development. Yard. Doç. Dr. Tacha Serif Department of Computer Engineering Yeditepe University

Android 5.0: Lollipop OS

CS378 -Mobile Computing. Android Overview and Android Development Environment

H MICRO CASE STUDY. Device API + IPC mechanism. Electrical and Functional characterization of HMicro s ECG patch

Example of Standard API

Accessing I2C devices with Digi Embedded Linux 5.2 example on Digi Connect ME 9210

Smartphone market share

Università Degli Studi di Parma. Distributed Systems Group. Android Development. Lecture 1 Android SDK & Development Environment. Marco Picone

Overview of CS 282 & Android

Creating secure web based user interfaces for Embedded Devices

Investigating sensors support in a tablet

Introduction to Android Development. Jeff Avery CS349, Mar 2013

ANDROID. Programming basics

Android Development. Lecture AD 0 Android SDK & Development Environment. Università degli Studi di Parma. Mobile Application Development

Freescale Semiconductor, I

Graduate presentation for CSCI By Janakiram Vantipalli ( Janakiram.vantipalli@colorado.edu )

AllJoyn Android Environment Setup Guide

Fitness Motion Recognition

Example Connection between USB Host and Android

OMX, Android, GStreamer How do I decide what to use? 15 July 2011

Android Basics. Xin Yang

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Questions from The New SensorTag - IoT Made Easy Webinar

Common clock framework: how to use it

file://d:\webs\touch-base.com\htdocs\documentation\androidplatformnotes52.htm

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Publishing to TIZEN Using the Automated Conversion/Repackaging of Existing Android Apps. Hyeokgon Ryu, Infraware Technology, Ltd.

PART I: WELCOME TO THE WONDERFUL WORLD OF ACCESSORIES CHAPTER 1: INTRODUCTION TO ANDROID OPEN ACCESSORY 3

Android Sensors. CPRE 388 Fall 2015 Iowa State University

Introduction to Native Android Development with NDK

Iotivity Programmer s Guide Soft Sensor Manager for Android

Programming with Android

Complete Integrated Development Platform Copyright Atmel Corporation

Multicast File and Screen Sharing using Wi-Fi Connectivity

An Introduction to Android

@ME (About) Marcelo Cyreno. Skype: marcelocyreno Linkedin: marcelocyreno Mail:

Mobile Operating Systems Lesson 03 PalmOS Part 1

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

Using the Android Sensor API

White Paper. Real-time Capabilities for Linux SGI REACT Real-Time for Linux

ELCE Secure Embedded Linux Product (A Success Story)

GS-SL2X00 Series. GS-WTX00 Series. Enterprise Android Barcode Device. User Manual

! Sensors in Android devices. ! Motion sensors. ! Accelerometer. ! Gyroscope. ! Supports various sensor related tasks

Mobile Technologies Index

AT12181: ATWINC1500 Wi-Fi Network Controller - AP Provision Mode. Introduction. Features. Atmel SmartConnect APPLICATION NOTE

An Introduction to Android. Huang Xuguang Database Lab. Inha University

Disfer. Sink - Sensor Connectivity and Sensor Android Application. Protocol implementation: Charilaos Stais (stais AT aueb.gr)

MOVEIRO BT-200 Technical Information for Application Developer

Embedded Linux Platform Developer

Do More With Less. On Driver-less Interfacing with Embedded Devices. Peter Korsgaard

Technology in Action. Alan Evans Kendall Martin Mary Anne Poatsy. Eleventh Edition. Copyright 2015 Pearson Education, Inc.

Google Android: An Emerging Innovative Software Platform For Mobile Devices

DOCUMENT REFERENCE: SQ EN. SAMKNOWS SMARTPHONE-BASED TESTING SamKnows App for Android White Paper. May 2015

APPLICATION NOTE. AT17284: Proximetry Cloud Based Smart Plug User Guide. SMART ARM-based Microcontrollers. Introduction. Features

Open Network Linux. A Path to an Open Source Network OS. Rob Sherwood Big Switch Networks CTO

Camera Sensor Driver Development And Integration

Training. NFC in Android. Public. MobileKnowledge October 2015

The BSN Hardware and Software Platform: Enabling Easy Development of Body Sensor Network Applications

Datacenter Operating Systems

Tutorial on Basic Android Setup

Evolution of Smartphones And Android Operating System

Super Manager User Manual. English v /06/15 Copyright by GPC

Transcription:

Android Sensors 101 Atilla Filiz atilla@mind.be 2014 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License CC-BY Google

These slides are made available to you under a Creative Commons Share-Alike 3.0 license. The full terms of this license are here: https://creativecommons.org/licenses/by-sa/3.0/ This document contains excerpts from other documents published under a similar license, including: http://www.opersys.com/training/embedded-android by Karim Yaghmour Copyright 2010-2013, Opersys inc. http://www.opersys.com/training/android-development by Karim Yaghmour Copyright 2010-2012, Opersys inc. Android Sensors Training by Arnout Vandecappelle and Atilla Filiz Copyright 2013 Essensium NV Attribution requirements and misc. This slide must remain as-is in this specific location (slide #2), everything else you are free to change; including the logo :-) Use of figures in other documents must feature the below Originals at URL immediately under that figure and the below copyright notice where appropriate.

Why A smartphone... is more than a phone is more* than a PC is aware of its surroundings Acceleration Rotation Magnetism Humidity Air pressure Temperature Light Proxymity * Some restrictions apply

Outline The Android software stack Differences with normal Linux Android sensor architecture Hardware components Hardware abstraction layer Sensor types How to introduce new sensors Power considerations Sensor fusion What is it? Implementation options

Android is an... API for developing Apps Java based But also compiled source code is possible SDK for developing Apps open source implementation of that API: AOSP Based on a modified Linux kernel Using a few other open source tools With many packages Google

Androidisms and the Linux kernel Androidisms Wakelocks (power management) lowmem handler Binder (IPC mechanism) ashmem Anonymous Shared Memory RAM console Logger Some are already in mainline(3.8+) Device makers lag behind the mainline No change in device drivers or board files SoC vendors do the kernel porting https://android.googlesource.com/kernel/common/

The Android wall Apps developer.android.com Device source.android.com

The Android wall Apps developer.android.com API level SDK Android version Device source.android.com

The Android wall Apps developer.android.com API level SDK Android version Focus of today Device source.android.com

Overview of the Android stack @MarkoGargenta https://thenewcircle.com/s/post/1044/remixing_android Android on non-mobile 10

Android Sensor Architecture Application Framework User space Hardware abstraction Drivers Kernel space Hardware (Chips & Bits)

Hardware Sensor chips Sensor interface (i2c, spi, usb etc.) Sensor hub SDA Aggregate data Control signals SoC SCL SCL Hub Gyro Mag Accel SDA Easy to manage Power saving by turning off main CPU Interrupts Offload processing Filtering Fusion

Hardware Abstraction Layer Written in C++ Main tasks are: Communication via sysfs nodes Callbacks for framework requests Sensors can be virtualized at this level

Hardware Abstraction Layer hardware/invensense/libsensors_iio/compasssensor.iio.9150.h class CompassSensor : public SensorBase { public: CompassSensor(); virtual ~CompassSensor(); virtual int getfd() const; virtual int enable(int32_t handle, int enabled); virtual int setdelay(int32_t handle, int64_t ns); virtual int getenable(int32_t handle); virtual int64_t getdelay(int32_t handle); // unnecessary for MPL virtual int readevents(sensors_event_t *data, int count) { return 0; } int readsample(long *data, int64_t *timestamp); int providescalibration() { return 0; } void getorientationmatrix(signed char *orient); long getsensitivity(); int getaccuracy() { return 0; } void filllist(struct sensor_t *list); int isintegrated() { return (mi2cbus == COMPASS_BUS_SECONDARY); } private:. } hardware/invensense/libsensors_iio/android.mk: LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp

Hardware Abstraction Layer device/samsung/tuna/libsensors/sensors.cpp static struct sensor_t ssensorlist[local_sensors + MPLSensor::numSensors] = { { "GP2A Light sensor", "Sharp", 1, SENSORS_LIGHT_HANDLE, SENSOR_TYPE_LIGHT, powf(10, 125.0f/ 24.0f) * 4, 1.0f, 0.75f, 0, { } }, { "GP2A Proximity sensor", "Sharp", 1, SENSORS_PROXIMITY_HANDLE, SENSOR_TYPE_PROXIMITY, 5.0f, 5.0f, 0.75f, 0, { } }, { "BMP180 Pressure sensor", "Bosch", 1, SENSORS_PRESSURE_HANDLE, SENSOR_TYPE_PRESSURE, 1100.0f, 0.01f, 0.67f, 20000, { } }, };

Framework Implemented in Java Passes subscriptions to HAL Passes sensor events to apps No hardware specific code here Generic filtering/virtualization/fusion

Adding New Sensors Sensor hub firmware (if any) Kernel drivers The usual Linux way Interrupts, work queues etc. Hardware abstraction layer Edit existing libsensors Just add own sensor to sensors.cpp if you have a regular sensor Add new library For a new type of sensor See hardware/libhardware/include/hardware/sensors.h

Sensor types(1/2) #define SENSOR_TYPE_ACCELEROMETER (1) #define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) #define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD #define SENSOR_TYPE_ORIENTATION (3) #define SENSOR_TYPE_GYROSCOPE (4) #define SENSOR_TYPE_LIGHT (5) #define SENSOR_TYPE_PRESSURE (6) #define SENSOR_TYPE_TEMPERATURE (7) #define SENSOR_TYPE_PROXIMITY (8) #define SENSOR_TYPE_GRAVITY (9) #define SENSOR_TYPE_LINEAR_ACCELERATION (10) #define SENSOR_TYPE_ROTATION_VECTOR (11) #define SENSOR_TYPE_RELATIVE_HUMIDITY (12) #define SENSOR_TYPE_AMBIENT_TEMPERATURE (13) #define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14) #define SENSOR_TYPE_GAME_ROTATION_VECTOR (15) #define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16) #define SENSOR_TYPE_SIGNIFICANT_MOTION (17) #define SENSOR_TYPE_STEP_DETECTOR (18) #define SENSOR_TYPE_STEP_COUNTER (19) #define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20)

Sensor types(2/2) Real sensors: SENSOR_TYPE_GEOMAGNETIC_FIELD: Magnetic field strength in (x,y,z) relative to device, in ut, including all compensations Virtual sensors: SENSOR_TYPE_GEOMAGNETIC_ROTATION_V ECTOR: Virtual sensor that gives rotation vector, using magnetometer.

Coordinate system

Sensor working modes Continuous Fixed interval, set by setdelay() On change When the value changes With a minimum time between events One-shot SW activates sensor Sensor detects event/takes sample Sensor deactivates self SW event is created Special Sensor type dependant

Power considerations Wake up main CPU? The default answer is NO. Any generated events are dropped. An app can hold a wakelock if always-on is desired. Some sensors (eg. Proximity) always wake up the CPU. Respond to subscribe/unsubscribe. Apps unsubscribe when they are not listening. Turn off sensors when no subscription Might need to keep on for e.g. continuous calibration Add a timeout

Wakelocks Predefined in the API, no custom wakelocks No sensor specific locks, but that is not necessary

Sensor Fusion Higher accuracy Possibly faster convergence Higher power cost Can be done in different ways In the hardware In the framework In the application

Sensor Fusion Sensor 1 Sensor 2 Sensor 3 MAGIC Data More Data Magic == Kalman Filter? Simpler algorithms also possible Physical model

Sensor Fusion Complementary filter(by Shane Colton, MIT) Image by Paul Lawitzky

Sensor Fusion may happen... In hardware (sensor hub firmware) If you are a device or sensor maker Run the fusion algorithm on the hub. Add a virtual sensor driver to the kernel. In the framework If you are a device maker, AOSP contributor Hardware agnostic Exists in Android 4.x In app If you are an app developer Subscribe to multiple sensors Process the events in your app logic Use NDK if necessary

That's all folks! Questions?

www.mind.be www.essensium.com Essensium NV Mind - Embedded Software Division Gaston Geenslaan 9, B-3001 Leuven Tel : +32 16-28 65 00 Fax : +32 16-28 65 01 email : info@essensium.com

References http://developer.android.com Presentation on sensors: http://www.slideshare.net/cvs26/sensors-on-android-10220894 Example fusion application: http://www.thousand-thoughts.com/2012/03/android-sensor-fusiontutorial/ SensorManager API for Apps: http://developer.android.com/reference/android/hardware/sensorm anager.html Course page on sensor fusion: http://www.control.isy.liu.se/student/tsrt14/

Android userspace Custom, limited libc: bionic Custom, limited shell and tools Different directory structure /system/ System files, apps etc /data/ user data, storage for apps /sdcard/ mount point for default sdcard Normal Linux tree can be installed side by side if needed

Android codenames Code name Version API level... Eclair 2.0 5 Eclair 2.0.1 6 Eclair 2.1 7, NDK 3 Froyo 2.2.x 8, NDK 4 Gingerbread 2.3 2.3.2 9, NDK 5 Gingerbread 2.3.3 2.3.7 10... Ice Cream Sandwich (ICS) 4.0.1 4.0.2 14, NDK 7 Ice Cream Sandwich (ICS) 4.0.3 4.0.4 15, NDK 8 Jelly Bean 4.1.x 16 Jelly Bean 4.2.x 17 Jelly Bean 4.3.x 18 KitKat 4.4 19 http://source.android.com/source/build-numbers.html

Sensor Fusion in Hardware Use an external uc as a sensor hub. Run the fusion algorithm on the hub. Add a virtual sensor driver to the kernel. Real-time accuracy Doesn't bother main CPU Might save power (main CPU off) Cost of additional hardware Hub firmware is device-dependent But several sensors + hub can be bundled

Sensor Fusion in Framework Somewhat present in Android 4. Run the fusion in the framework code. Virtual sensors are supported in the in the framework. Generate events with fused data. Does not require additional hardware. Sensor-agnostic. Takes up main CPU time/energy. No real-time guarantee.

Sensor Fusion in App Platform-agnostic Probe raw-data and fuse to make sure. Or probe for fused sensors and fall back on own code. Example: Orientation Listen for acc, mag and gyro events. Acc or mag event getrotationmatrix(r, null, acc, mag); getorientation(r, O_accmag); Gyro event: dt=event.time prevtime; rot_gyro=gyro*dt; O_final = k_gyr*rot_gyro + k_accmag*o_accmag Or Kalman Filter Takes up main CPU time/energy. No real-time guarantee.

So how do I do fusion? Nothing (Android 4.x has in framework) Hardware bundle Framework patch App