23
Real-Time Sensing on Android Reliable Mobile Systems Group Fiji Systems Inc. Yin Yan, Shaun Cosgrove, Ethan Blanton, Steven Y. Ko, Lukasz Ziarek http://rtdroid.cse.buffalo.edu

Real-Time Sensing on Android

Embed Size (px)

DESCRIPTION

Real-Time Sensing on Android. Reliable Mobile Systems Group Fiji Systems Inc. Yin Yan , Shaun Cosgrove, Ethan Blanton, Steven Y. Ko , Lukasz Ziarek. Evaluating Android OS for Embedded Real-Time Systems Android and RTOS together: - PowerPoint PPT Presentation

Citation preview

Page 1: Real-Time Sensing on Android

Real-Time Sensing on Android

Reliable Mobile Systems Group

Fiji Systems Inc.Yin Yan, Shaun Cosgrove,

Ethan Blanton, Steven Y. Ko, Lukasz Ziarek

http://rtdroid.cse.buffalo.edu

Page 2: Real-Time Sensing on Android

Interest in Real-Time Android

• Evaluating Android OS for Embedded Real-Time Systems• Android and RTOS together: The dynamic duo for today’s medical devices• RTAndroid:

•A real-time extension to Android with non-blocking GC

• RTDroid:•RTOS + RTVM + RT-Android Framework

http://rtdroid.cse.buffalo.edu 2 / 19

Page 3: Real-Time Sensing on Android

http://rtdroid.cse.buffalo.edu

• Indoor Positioning• Inertial sensor data• Bluetooth• GSM• Wireless Lan

• Wearable • Tracking activity• Sleeping quality• Daily calorie

consumption

Sensor Event Driven Apps in Mobile

3 / 19

Page 4: Real-Time Sensing on Android

http://rtdroid.cse.buffalo.edu

Sensor Event Driven Apps in Real-time

GPS

inertial measurement unit

Camera and antenna pointing

Stabilization

4 / 19

Page 5: Real-Time Sensing on Android

http://rtdroid.cse.buffalo.edu

Requirement for Sensor Architecture• Traditional mobile sensing app

• Multi sensors• Multi components• Hardware control

• Real-time sensing app• Predictability in data delivery

5 / 19

Page 6: Real-Time Sensing on Android

Available Sensors in Android

• Hardware sensor Accelerometer Ambient temperature Geomagnetic field Gyroscope Light Pressure Humidity

• Software Sensors Linear acceleration Significant motion Step detector Step counter Rotation sensor Game rotation vector Gravity Magnetometer Orientation …

http://rtdroid.cse.buffalo.edu 6 / 19

Page 7: Real-Time Sensing on Android

http://rtdroid.cse.buffalo.edu

What Does the Android Sensor Architecture Provide?

Application Sensor Manager

SensorEventListener

Accelerometer

Gyroscope

Magnetometer

enable/disable

Change sampling rate

Subscript sensor event

7 / 19

Page 8: Real-Time Sensing on Android

SensorEvent

Listener

SensorService

InputEvent

SensorManger

HAL

How Does Android Sensor Manager Work?

SensorFusion

SensorThread

EventQueue

NativeSensorManger

SensorThread

Kernel SystemRuntime

Framework Application

http://rtdroid.cse.buffalo.edu 8 / 19

Page 9: Real-Time Sensing on Android

What Happens In a Real-Time Context?

Accelerometer Data

Gyroscope Data

• One application is listening on two sensorsAccelerometer with higher priorityGyroscope with lower priority

Kernel

Application

Unbound Delivery Time

Android Framework

http://rtdroid.cse.buffalo.edu 9 / 19

Page 10: Real-Time Sensing on Android

RT SensorManager

• Event-driven architecture• Polling and processing thread

• Receiver-based priority inheritance• Polling and processing inherit the highest priority

of the receivers• RT-Handler for delivery sensor events with to

different receivers

http://rtdroid.cse.buffalo.edu 10 / 19

Page 11: Real-Time Sensing on Android

RT-Handler

RT SensorManager

PollingThreads

ProcessingThreads

gyroscope

Accelerometer Handler

Handler

gyroscope

Accelerometer

http://rtdroid.cse.buffalo.edu 11 / 19

Apps

Accel Listener

Gyroscope Listener

P1

P2

P2

P1

P1

P1

P2

P2

P1 > P2

Page 12: Real-Time Sensing on Android

Evaluation on jPapabench

http://rtdroid.cse.buffalo.edu 12 / 19

Page 13: Real-Time Sensing on Android

Porting jPapaBench into RTDroid

Fly-By-Wired (FBW) Simulation Autopilot

SensorManager

TestPPMTaskHandler

SendDataToAutopolit

CheckFailsafeTaskHandler

CheckMega128ValuesTaskHandler

SimulatorFlightModelTaskHandler

SimulatorIRTaskHandler

SimulatorGPSTaskHandler

NavigationTaskHandler

StablizationTaskHandler

AltitudeControlTaskHandler

Data injection Data subscription

http://rtdroid.cse.buffalo.edu 13 / 19

Page 14: Real-Time Sensing on Android

Simulated workload: • Memory intensive load: allocating a 2.5 MB integer array

every 20ms• Computation intensive load: tight loop performing a

floating point multiplication every 20ms• Client intensive load: 1 higher priority a listener with

number of lower priority listeners

Evaluation on jPapabench

Measurement: The latency of the IR sensor data delivery

Time cost from the time of sensor data buffered to the time of the sensor data delivered in IR Sensor reading task

http://rtdroid.cse.buffalo.edu 14 / 19

Page 15: Real-Time Sensing on Android

RT Linux RTEMS

Soft Real-time Smartphone ARM Cortex-A8 1000MHz 512 MB memory Android 4.1.1 on Linux 3.0

with real time patch

Hard Real-time Embedded

SPARC, Leon3, 50 MHz 8MB flash PROM 64MB SDRAM RTEMS 4.9.4

Evaluation Platforms

http://rtdroid.cse.buffalo.edu 15 / 19

Page 16: Real-Time Sensing on Android

RTEMS

Evaluation for Java Autopilot

Base line performance on Nexus S

Base line performance on LEON3

http://rtdroid.cse.buffalo.edu 16 / 19

Page 17: Real-Time Sensing on Android

RTEMS

Evaluation for Java Autopilot

RT SensorManager stress tests on LEON3

http://rtdroid.cse.buffalo.edu 17 / 19

Page 18: Real-Time Sensing on Android

Future Extensions to jPapabench

http://rtdroid.cse.buffalo.edu 18 / 19

Flight dynamic modelIR & GPS

• Connect jPapabench with physical simulator• Drivers in kernel for RTDroid SensorManager

jPapabenchApplication

Simulator in Paparazzi Sensor

Manager

Kernel Driver

Page 19: Real-Time Sensing on Android

Future extensions to jPapabench

PaparazzijPapabench

http://rtdroid.cse.buffalo.edu 19 / 19

Page 20: Real-Time Sensing on Android

• Real-time extension of Android manifest for off-line analysis and resource pre-allocation

• Programming model design with scoped memory

• Multi-application execution in partitioned system

• Alterative of Binder for inter-process communication

Future Work on RTDroid

http://rtdroid.cse.buffalo.edu 20 / 19

Thanks

Page 22: Real-Time Sensing on Android

Application: soft real-time fall detector

Simulated workload: • Memory intensive load: allocating a 2.5 MB integer array every

20ms• Computation intensive load: tight loop performing a floating point

multiplication every 20ms

http://rtdroid.cse.buffalo.edu

Evaluation for RT Sensor Architecture

Measurement: the latency of the sensor data delivery

Time cost from the time of sensor data buffered in kernel to the time of the sensor data delivered in application

Page 23: Real-Time Sensing on Android

RTEMS

Memory stress test for the fall detection app on Nexus S

http://rtdroid.cse.buffalo.edu

Evaluation for RT Sensor Architecture