X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation...

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

Transcript of X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation...

Page 1: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

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

Page 2: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

AGENDA

• Intro

•Concept

•APIs

•Experiments

Page 3: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

INTRODUCTION

Page 4: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

CORE MOTION WILL

• Provide raw Accelerometer & Gyroscope data

• Provide relatively High-Level filtering

• Provide separated Acceleration, Gravity, Rotation Rate, Attitude

Page 5: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

CORE MOTION WON’T

• Give you GPS Data

• Give you Compass Data

• Allow easy management of high-level Motion Events

Page 6: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

CONCEPTS

Page 7: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

ACCELERO–METER

Measures 3-Axis-Gravity

Available since iPhone 1

Relatively noisy

Page 8: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

STMicro STM33DH 3-axis accelerometer

Page 9: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

GYROSCOPEMeasures 3-Axis-Rotation

New in iPhone 4

Relatively precise

Page 10: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

STMicro AGD1 3-Axis-Gyroscope

Up to 2500 °/s ±0.03 °/s

Page 11: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

X

Z

roll

yaw

pitch

Y

Page 12: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

Accelerometer Gyroscope

X/ Y/Z Pitch/Roll/Yaw

Device Motion

Acceleration / GravityRotation Rate / Attitude

Page 13: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

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: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

API

Page 15: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

- timestamp

CMLogItem

- pitch, roll, yaw

CMGyroData- x, y, z

CMAccelerometerData

- accel, gravity, rotationRate

CMDeviceMotion

- pitch, roll, yaw

CMAttitude

- start, stop

CMMotionManager

Page 16: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

CMMotionManager

- is<Accelerometer|DeviceMotion|Gyro>Available

- is<…>Active

- set<…>UpdateInterval

- start<…>UpdatesToQueue:WithHandler :

- stop<…>Updates

Page 17: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

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: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

CMLogItem

• Abstract superclass

•Only contains -timestamp property

Page 19: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

CMAccelerometerData

X

Z

Y

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

Measured in G

Page 20: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

You aren’t going to need itroll

yaw

pitch

CMGyroData

Measured in radian

Page 21: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

CMDeviceMotion

• CMAttitude attitude

• CMRotationRate rotationRate

• CMAcceleration gravity

• CMAcceleration userAcceleration

Page 22: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

CMAttitude

• Yaw, Pitch, Roll

• Also as Rotation Matrix!

Page 23: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

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: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

EXPERIMENT

Page 25: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

DEMO

Page 26: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

THANK YOU!

Page 27: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

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: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

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: X/Y/Z/PITCH/ROLL/YAW€¦ · X/ Y/Z Pitch/Roll/Yaw Device Motion Acceleration / Gravity Rotation Rate / Attitude. CREATIVE USES

files.ludwigschubert.de/cm.pdf