Tegra Android Accelerometer Whitepaper

Similar documents
Black-Scholes option pricing. Victor Podlozhnyuk

Binomial option pricing model. Victor Podlozhnyuk

HP TouchPad Sensor Setup for Android

How To Write A Cg Toolkit Program

Android Sensors. CPRE 388 Fall 2015 Iowa State University

Technical Brief. DualNet with Teaming Advanced Networking. October 2006 TB _v02

Technical Brief. Introducing Hybrid SLI Technology. March 11, 2008 TB _v01

NVIDIA VIDEO ENCODER 5.0

QUADRO POWER GUIDELINES

NVIDIA Tegra Android Platform Support Pack Getting Started Guide

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

NVIDIA Tesla Compute Cluster Driver for Windows

Atlas Creation Tool Using the Command-line Tool

Parallel Prefix Sum (Scan) with CUDA. Mark Harris

Whitepaper. NVIDIA Miracast Wireless Display Architecture

NVIDIA CUDA GETTING STARTED GUIDE FOR MAC OS X

Sensors & Motion Sensors in Android platform. Minh H Dang CS286 Spring 2013

NVIDIA GeForce GTX 580 GPU Datasheet

OpenCL Programming for the CUDA Architecture. Version 2.3

NVIDIA CUDA GETTING STARTED GUIDE FOR MAC OS X

TEGRA LINUX DRIVER PACKAGE R21.1

DUAL MONITOR DRIVER AND VBIOS UPDATE

AN4156 Application note

Monte-Carlo Option Pricing. Victor Podlozhnyuk

Making Android Motion Applications Using the Unity 3D Engine

Technical Brief. NVIDIA nview Display Management Software. May 2009 TB _v02

GRID VGPU FOR VMWARE VSPHERE

XID ERRORS. vr352 May XID Errors

NVIDIA Mosaic Technology

NVIDIA CUDA GETTING STARTED GUIDE FOR MICROSOFT WINDOWS

3D Tranformations. CS 4620 Lecture 6. Cornell CS4620 Fall 2013 Lecture Steve Marschner (with previous instructors James/Bala)

How to Convert 3-Axis Directions and Swap X-Y Axis of Accelerometer Data within Android Driver by: Gang Chen Field Applications Engineer

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

NVIDIA NVIEW DESKTOP MANAGEMENT SOFTWARE

Technical Brief. Quadro FX 5600 SDI and Quadro FX 4600 SDI Graphics to SDI Video Output. April 2008 TB _v01

Writing Applications for the GPU Using the RapidMind Development Platform

QUADRO AND NVS DISPLAY RESOLUTION SUPPORT

Workstation Applications for Windows. NVIDIA MAXtreme User s Guide

Essential Mathematics for Computer Graphics fast

SolarWinds. Understanding SolarWinds Charts and Graphs Technical Reference

Motorola 8- and 16-bit Embedded Application Binary Interface (M8/16EABI)

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

Running Windows 8 on top of Android with KVM. 21 October Zhi Wang, Jun Nakajima, Jack Ren

CS 4620 Practicum Programming Assignment 6 Animation

Module 1: Sensor Data Acquisition and Processing in Android

HybriDroid: Analysis Framework for Android Hybrid Applications

The C Programming Language course syllabus associate level

NVIDIA GeForce Experience

ELET4133: Embedded Systems. Topic 15 Sensors

NVIDIA GRID 2.0 ENTERPRISE SOFTWARE

Cisco Cius Development Guide Version 1.0 September 30, 2010

NVIDIA WMI. WP _v02 August White Paper

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

REPAIRING THE "ORACLE VM VIRTUALBOX" VIRTUAL MACHINE PROGRAM

Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers. 8-bit Atmel Microcontrollers. Application Note.

GRID LICENSING. DU April User Guide

Fitness Motion Recognition

Intel Media SDK Library Distribution and Dispatching Process

A Adobe RGB Color Space

Lecture 1 Introduction to Android

Content. Chapter 4 Functions Basic concepts on real functions 62. Credits 11

Intel Retail Client Manager Audience Analytics

CA Service Desk Manager - Mobile Enabler 2.0

Therm-App Software Development Kit License Agreement

Kathy Au Billy Yi Fan Zhou Department of Electrical and Computer Engineering University of Toronto { kathy.au, billy.zhou }@utoronto.

ORACLE ADF MOBILE DATA SHEET

ORACLE MOBILE APPLICATION FRAMEWORK DATA SHEET

Android Sensor Programming. Weihong Yu

NVIDIA CUDA INSTALLATION GUIDE FOR MICROSOFT WINDOWS

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

Moven Studio realtime. streaming

NVIDIA GRID DASSAULT CATIA V5/V6 SCALABILITY GUIDE. NVIDIA Performance Engineering Labs PerfEngDoc-SG-DSC01v1 March 2016

WEARIT DEVELOPER DOCUMENTATION 0.2 preliminary release July 20 th, 2013

Introduction to NaviGenie SDK Client API for Android

Software Solutions for Multi-Display Setups

TESLA C2050/2070 COMPUTING PROCESSOR INSTALLATION GUIDE

Fast Arithmetic Coding (FastAC) Implementations

USB 3.0 ADOPTERS AGREEMENT

Power Benefits Using Intel Quick Sync Video H.264 Codec With Sorenson Squeeze

NVIDIA Jetson TK1 Development Kit

MULTIFUNCTIONAL DIGITAL SYSTEMS. Network Fax Guide

NVIDIA GRID K1 GRAPHICS BOARD

AN3998 Application note

AN AES encryption and decryption software on LPC microcontrollers. Document information

Copyright Notice. Mobile Testing Enterprise 7.3. September Copyright Keynote LLC. All rights reserved.

GPU Christmas Tree Rendering. Evan Hart

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

Solar Shading Android Application v6.0. User s Manual

ADF Mobile Overview and Frequently Asked Questions

An Introduction to Android Application Development. Serdar Akın, Haluk Tüfekçi

Mail Programming Topics

Transcription:

Tegra Android Accelerometer Whitepaper Version 5-1 -

Contents INTRODUCTION 3 COORDINATE SPACE GLOSSARY 4 ACCELEROMETER CANONICAL AXES 6 WORKING WITH ACCELEROMETER DATA 7 POWER CONSERVATION 10 SUPPORTING OLDER OS VERSIONS 11-2 -

Introduction Portable devices can be used in a variety of orientations. Applications need to consider the ways in which orientation affects them, such as a custom UI for landscape versus portrait modes, or interpreting raw sensor data. Applications making use of the accelerometer must take special care when processing the raw data, given device and operating system expectations, in order to deliver a proper user experience. While the accelerometer is an important input device to many software applications, some developers are using incorrect methods to process the accelerometer data. More to the point, these applications are not taking into account device orientation, which results in a poor if not failed user experience. Proper orientation handling of accelerometer input is a simple matter, which we will discuss in the sections that follow. - 3 -

Coordinate Space Glossary Android reports accelerometer values in absolute terms. The values reported are always the data from the physical sensor adjusted to match the Android canonical format so that all devices report such data in the same fashion. Android does not transform accelerometer data to be relative to the device orientation. Applications requiring this must perform their own transformations. To that end, this document uses the following definitions of coordinate spaces and coordinate space transformations to maintain consistency: Space Device Raw Canonical Description The accelerometer device can output acceleration values in a variety of ways and is not subject to any particular standard. Android specifies that the coordinate frame outputted by the driver must remap Device Raw so that the positive X axis is oriented increasing to the right side of the device, the positive Y axis should be increasing to the top of the device, and the positive Z axis is increasing out the display of the device towards the user. See the Accelerometer Canonical Axes reference below for further visual guide to Canonical accelerometer layout. Screen World The Android window manager s screen coordinate origin is at the upper left corner and the maximum coordinate is at the lower right corner, i.e. increasing x is right, increasing y is down. Android s display manager will change the screen orientation based on sensor readings. The screen coordinate system is always relative to the current rotation. This coordinate space is specific to OpenGL ES applications. App developers may need to alter the sample code to fit their assumptions in this regard. In this document, it is assumed that applications are using a right-handed coordinate system, up can be any arbitrary vector. NOTE: Many applications will require additional transforms to those shown here to orient their models. Apps using left-handed coordinates may require an additional coordinate inversion as well. - 4 -

Source The table below shows transforms of interest and defines a vocabulary for this paper. OpenGL applications will typically be using canontoworld. Android windowing system based applications will use canontoscreen. Hybrid applications, such as OpenGL applications that use the Android window system to render widgets, will require both. NOTE: The accelerometer device driver handles conversion into Canonical space (handling the devicetocanon transform), this whitepaper focuses on the canontoscreen and canontoworld transformations. Destination Canonical Screen World Device Raw devicetocanon Canonical canontoscreen canontoworld - 5 -

Accelerometer Canonical Axes The following visuals show the variation in accelerometer values based upon given device and orientation. They include a portrait-native device, a portrait device rotated to landscape, and a landscape-native device, with Canonical x/y/z accelerometer axes/values labeled. Phone Device Portait Native Orientation 0 Phone Device Portrait Native Orientation 90 Tablet Device Landscape Native Orientation 0-6 -

Working with Accelerometer Data Where screen-relative results are desired, the accelerometer values must be rotated according to the display orientation returned by the Android API s getorientation() or getrotation() functions. Both functions return the same values, but the former is a deprecated usage. The value returned from these functions corresponds to the integers/constants defined in Android.view.Surface, those prefixed with ROTATION_. Below is an example of the invocation of one of these functions. Here this is of type Activity. WindowManager windowmgr = (WindowManager)this.getSystemService(WINDOW_SERVICE); int rotationindex = windowmgr.getdefaultdisplay().getrotation(); The returned constants are: constant name index/value ROTATION_0 0 ROTATION_90 1 ROTATION_180 2 ROTATION_270 3 Applications can use the rotation value to construct a transformation matrix that will convert Android Canonical accelerometer data to other coordinate spaces. In order to transform from Canonical aligned accelerometer values into either screen or world aligned accelerometer values, a canonaccel vector needs to be rotated by 90 degree increments based on the rotationindex, (where ROTATION_0 means no rotation is necessary). For the canontoscreen transform, the rotations follow these equations: - 7 -

Where: A function implementing the canontoscreen transform follows. static void canonicaltoscreen(int displayrotation, float[] canvec, float[] screenvec) struct AxisSwap signed char negatex; signed char negatey; signed char xsrc; signed char ysrc; ; static const AxisSwap axisswap[] = 1, -1, 0, 1, // ROTATION_0-1, -1, 1, 0, // ROTATION_90-1, 1, 0, 1, // ROTATION_180 1, 1, 1, 0 ; // ROTATION_270 const AxisSwap& as = axisswap[displayrotation]; screenvec[0] = (float)as.negatex * canvec[ as.xsrc ]; screenvec[1] = (float)as.negatey * canvec[ as.ysrc ]; screenvec[2] = canvec[2]; For the canontoworld transform, the rotations follow these equations instead: This axis-aligned transformation can be put into a static array, as shown below in the canonicaltoworld() function that uses a simple integer lookup array to avoid costly trigonometric functions when converting a canonical space accelerometer vector into an OpenGL-style world space vector. - 8 -

static void canonicaltoworld( int displayrotation, const float* canvec, float* worldvec) struct AxisSwap signed char negatex; signed char negatey; signed char xsrc; signed char ysrc; ; static const AxisSwap axisswap[] = 1, 1, 0, 1, // ROTATION_0-1, 1, 1, 0, // ROTATION_90-1, -1, 0, 1, // ROTATION_180 1, -1, 1, 0 ; // ROTATION_270 const AxisSwap& as = axisswap[displayrotation]; worldvec[0] = (float)as.negatex * canvec[ as.xsrc ]; worldvec[1] = (float)as.negatey * canvec[ as.ysrc ]; worldvec[2] = canvec[2]; The next function will compute the axis-angle transform necessary to align a model s localup vector with that of the accelerometer. The function returns the vector (rotaxis) and angle (ang) which is sufficient to build a transformation matrix or to build a quaternion to orient a model vertically in World space. void computeaxisangle(const float* localup, const float* worldvec, float* rotaxis, float* ang) const Vec3& lup = *(Vec3*)localUp; Vec3 ntarget = normalize(*(vec3*)worldvec); *rotaxis = cross(lup, ntarget); *rotaxis = normalize(*rotaxis); *ang = -acosf(dot(lup, ntarget)); The NVIDIA Android NDK Samples includes library functions for building matrices and quaternions from the axis angle representation. It may be necessary to apply an additional rotation to orient objects in the plane orthogonal to the final world vector. - 9 -

Power Conservation In order to conserve device power, applications should choose the slowest accelerometer update rate possible to achieve the desired result. Values available for setting the update rate are defined in android.hardware.sensormanager and are listed below in order of decreasing update rate. constant name SENSOR_DELAY_FASTEST relative speed fastest SENSOR_DELAY_GAME faster SENSOR_DELAY_NORMAL slower SENSOR_DELAY_UI slowest A sample of setting the sensor update rate is shown below. if (msensormanager == null) msensormanager = (SensorManager)getSystemService(SENSOR_SERVICE); if (msensormanager!= null) msensormanager.registerlistener( this, msensormanager.getdefaultsensor(sensor.type_accelerometer), SENSOR_DELAY_GAME ); Note that the delay values are abstract, with values specific to a given device, and thus rates could vary significantly between different devices. The only way to guarantee a certain update rate is to measure the rate returned by a device at run time. - 10 -

Supporting Older OS Versions In order to support OS versions older than Android Froyo/v2.2, it may be necessary to rely on the older deprecated function, getorientation(). Below is a brief snippet of code illustrating dynamic function binding. Please note that getorientation() may disappear from future Android versions, so it may be most prudent to dynamically bind against both functions and use the one that is available. WindowManager wm; Method getrotation; wm = (WindowManager)this.getSystemService(WINDOW_SERVICE); Class<Display> c = (Class<Display>)wm.getDefaultDisplay().getClass(); Method[] methods = c.getdeclaredmethods(); String rotfnname = new String("getRotation"); for( Method method : methods ) Log.d("Methods", method.getname()); if( method.getname().equals( rotfnname )) getrotation = method; break; int orientation; Display display = wm.getdefaultdisplay(); if( getrotation!= null ) try Integer i = (Integer)getRotation.invoke(d); orientation = i.intvalue(); catch(exception e) else orientation = display.getorientation(); - 11 -

Notice ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, MATERIALS ) ARE BEING PROVIDED AS IS. NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. Information furnished is believed to be accurate and reliable. However, NVIDIA Corporation assumes no responsibility for the consequences of use of such information or for any infringement of patents or other rights of third parties that may result from its use. No license is granted by implication or otherwise under any patent or patent rights of NVIDIA Corporation. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. NVIDIA Corporation products are not authorized for use as critical components in life support devices or systems without express written approval of NVIDIA Corporation. Trademarks NVIDIA, the NVIDIA logo, Tegra, GeForce, NVIDIA Quadro, and NVIDIA CUDA are trademarks or registered trademarks of NVIDIA Corporation in the United States and other countries. Other company and product names may be trademarks of the respective companies with which they are associated. Copyright 2010 NVIDIA Corporation. All rights reserved. NVIDIA Corporation 2701 San Tomas Expressway Santa Clara, CA 95050 www.nvidia.com