core motion
DESCRIPTION
Apple FrameworkTRANSCRIPT
X/Y/Z/PITCH/ROLL/YAWGetting you started with CoreMotion
AGENDA
• Intro
•Concept
•APIs
•Experiments
INTRODUCTION
CORE MOTION WILL
• Provide raw Accelerometer & Gyroscope data
• Provide relatively High-Level filtering
• Provide separated Acceleration, Gravity, Rotation Rate, Attitude
CORE MOTION WON’T
• Give you GPS Data
• Give you Compass Data
• Allow easy management of high-level Motion Events
CONCEPTS
ACCELERO–METER
Measures 3-Axis-Gravity
Available since iPhone 1
Relatively noisy
STMicro STM33DH 3-axis accelerometer
GYROSCOPEMeasures 3-Axis-Rotation
New in iPhone 4
Relatively precise
STMicro AGD1 3-Axis-Gyroscope
Up to 2500 °/s ±0.03 °/s
X
Z
roll
yaw
pitch
Y
Accelerometer Gyroscope
X/ Y/Z Pitch/Roll/Yaw
Device Motion
Acceleration / GravityRotation Rate / Attitude
CREATIVE USES
• Steering wheel — Real Racing
•Water level — iHandy Level, etc.
• Photo stabilisation — camera+, etc.
• Instrument dynamics — GarageBand
• Can you think of something new?
API
- timestamp
CMLogItem
- pitch, roll, yaw
CMGyroData- x, y, z
CMAccelerometerData
- accel, gravity, rotationRate
CMDeviceMotion
- pitch, roll, yaw
CMAttitude
- start, stop
CMMotionManager
CMMotionManager
- is<Accelerometer|DeviceMotion|Gyro>Available
- is<…>Active
- set<…>UpdateInterval
- start<…>UpdatesToQueue:WithHandler :
- stop<…>Updates
CMMotionManager II
• Needs to be allocated & initialized only once
•Make it a (nonatomic, retain)-property
• Reference frame for attitude is fixed at initialization time!
CMLogItem
• Abstract superclass
•Only contains -timestamp property
CMAccelerometerData
X
Z
Y
typedef struct { double x; double y; double z;} CMAcceleration;
Measured in G
You aren’t going to need itroll
yaw
pitch
CMGyroData
Measured in radian
CMDeviceMotion
• CMAttitude attitude
• CMRotationRate rotationRate
• CMAcceleration gravity
• CMAcceleration userAcceleration
CMAttitude
• Yaw, Pitch, Roll
• Also as Rotation Matrix!
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!
EXPERIMENT
DEMO
THANK YOU!
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
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”
files.ludwigschubert.de/cm.pdf