core motion

29
X / Y / Z / PITCH / ROLL / YAW Getting you started with CoreMotion

Upload: sergio-gonzalez

Post on 14-Apr-2015

52 views

Category:

Documents


7 download

DESCRIPTION

Apple Framework

TRANSCRIPT

Page 1: Core Motion

X/Y/Z/PITCH/ROLL/YAWGetting you started with CoreMotion

Page 2: Core Motion

AGENDA

• Intro

•Concept

•APIs

•Experiments

Page 3: Core Motion

INTRODUCTION

Page 4: Core Motion

CORE MOTION WILL

• Provide raw Accelerometer & Gyroscope data

• Provide relatively High-Level filtering

• Provide separated Acceleration, Gravity, Rotation Rate, Attitude

Page 5: Core Motion

CORE MOTION WON’T

• Give you GPS Data

• Give you Compass Data

• Allow easy management of high-level Motion Events

Page 6: Core Motion

CONCEPTS

Page 7: Core Motion

ACCELERO–METER

Measures 3-Axis-Gravity

Available since iPhone 1

Relatively noisy

Page 8: Core Motion

STMicro STM33DH 3-axis accelerometer

Page 9: Core Motion

GYROSCOPEMeasures 3-Axis-Rotation

New in iPhone 4

Relatively precise

Page 10: Core Motion

STMicro AGD1 3-Axis-Gyroscope

Up to 2500 °/s ±0.03 °/s

Page 11: Core Motion

X

Z

roll

yaw

pitch

Y

Page 12: Core Motion

Accelerometer Gyroscope

X/ Y/Z Pitch/Roll/Yaw

Device Motion

Acceleration / GravityRotation Rate / Attitude

Page 13: Core Motion

CREATIVE USES

• Steering wheel — Real Racing

•Water level — iHandy Level, etc.

• Photo stabilisation — camera+, etc.

• Instrument dynamics — GarageBand

• Can you think of something new?

Page 14: Core Motion

API

Page 15: Core Motion

- timestamp

CMLogItem

- pitch, roll, yaw

CMGyroData- x, y, z

CMAccelerometerData

- accel, gravity, rotationRate

CMDeviceMotion

- pitch, roll, yaw

CMAttitude

- start, stop

CMMotionManager

Page 16: Core Motion

CMMotionManager

- is<Accelerometer|DeviceMotion|Gyro>Available

- is<…>Active

- set<…>UpdateInterval

- start<…>UpdatesToQueue:WithHandler :

- stop<…>Updates

Page 17: Core Motion

CMMotionManager II

• Needs to be allocated & initialized only once

•Make it a (nonatomic, retain)-property

• Reference frame for attitude is fixed at initialization time!

Page 18: Core Motion

CMLogItem

• Abstract superclass

•Only contains -timestamp property

Page 19: Core Motion

CMAccelerometerData

X

Z

Y

typedef struct { double x; double y; double z;} CMAcceleration;

Measured in G

Page 20: Core Motion

You aren’t going to need itroll

yaw

pitch

CMGyroData

Measured in radian

Page 21: Core Motion

CMDeviceMotion

• CMAttitude attitude

• CMRotationRate rotationRate

• CMAcceleration gravity

• CMAcceleration userAcceleration

Page 22: Core Motion

CMAttitude

• Yaw, Pitch, Roll

• Also as Rotation Matrix!

Page 23: Core Motion

CAN’T TEST ON SIMULATOR

• You will need an actual iPhone 4

•One could read the Mac’s Accelerometer and send it to the iPhone via network…

• But for usability tests you’d still need an iPhone!

Page 24: Core Motion

EXPERIMENT

Page 25: Core Motion

DEMO

Page 26: Core Motion

THANK YOU!

Page 27: Core Motion

SOURCES• Core Motion Framework Reference — © Apple Inc.

/SYSTEM/LIBRARY/FRAMEWORKS/COREMOTION.FRAMEWORK

• “Get Moving with Core Motion” — © Jonathan BlocksomHTTP://WWW.SLIDESHARE.NET/JBLOCKSOM/CORE-MOTION-PRESENTATION

•MEMS Gyroscope X-Ray / SEM pictures — © Chipworks Inc.HTTP://WWW.CHIPWORKS.COM/

• iPhone 4 Teardown pictures — CC BY-NC-SA: Andrew BookholtHTTP://WWW.IFIXIT.COM/TEARDOWN/IPHONE-4-GYROSCOPE-TEARDOWN/3156/1

• iPhone 4 Gyroscope Datasheet — © ST Mikro Inc.HTTP://WWW.ST.COM/STONLINE/PRODUCTS/LITERATURE/DS/17116.PDF

Page 28: Core Motion

FURTHER READING

• Core Motion Framework ReferenceIOS DEVELOPER LIBRARY — FRAMEWORKS — CORE SERVICES LAYER — COREMOTION

• Event Handling Guide for iOS“MOTION EVENTS” — SECTION “CORE MOTION”

•WWDC ’10 Sample Code“COREMOTIONTEAPOT”

Page 29: Core Motion

files.ludwigschubert.de/cm.pdf