get moving with core motion!

Download Get Moving With Core Motion!

If you can't read please download the document

Upload: olesia

Post on 25-Feb-2016

45 views

Category:

Documents


0 download

DESCRIPTION

Get Moving With Core Motion!. Jonathan Blocksom Tuesday Sept 28 2010 2:00 – 3:15 PM. http:// www.slideshare.net/jblocksom/core -motion-presentation. Agenda. Intro SDK Experiments Q & A Intro level, but lots of code. About Me. Jonathan Blocksom [email protected] - PowerPoint PPT Presentation

TRANSCRIPT

Core Motion

Get Moving With Core Motion!http://www.slideshare.net/jblocksom/core-motion-presentation

Jonathan BlocksomTuesday Sept 28 20102:00 3:15 PMAgendaIntroSDKExperimentsQ & A

Intro level, but lots of code

About MeJonathan [email protected]@jblocksomComputer Vision Software Engineer,SET CorpComputer Graphics backgroundSeveral years working with Remote Sensing3Meet Core Motion!Core Motion Framework:High level interface to the orientation and movement data from the device

Based on Accelerometer and GyroscopesAcceleration, Gravity, Rotational AccelerationHigh level filtering

Core Motion isntFor GPS dataThats Core Location (LocationManager)For Compass dataAlso Core LocationHigh Level Motion EventsOrientation changeShake events

Perfect

Quick DemoCoreMotionTeapot(WWDC 2010 sample code)

AccelerometerAvailable since iPhone 1Consider it a Gravity DetectorNoisy

iPad, iPhone 4:STMicro STM33DH3-axis accelerometer

Photo by David Hodsonhttp://www.ifixit.com/Guide/Image/meta/IP1qEpYFQSSqwSbgGyroscopesNew in iPhone 4, iPod Touch 4Detects rotation rate along three axisChip datasheet:http://www.st.com/stonline/products/literature/ds/17116.pdf200/500/2500 dps (degrees per second)0.03 dps error

Gyro Teardownhttp://www.ifixit.com/Teardown/iPhone-4-Gyroscope-Teardown/3156/1

Andrew Bookholt:http://www.ifixit.com/Guide/Image/meta/UurGsklhtJRW2uuB (left)http://www.ifixit.com/Guide/Image/meta/MeunHawo54qPRY5S (right 1)

Miroslav Djurichttp://www.ifixit.com/Guide/Image/meta/RUQLo2PP1oqVtVsD (right 2)

Accelerometer, Gyro & Device MotionAccelerometerGyroDevice Motionx, y, zyaw, pitch, rollGravityUser accelerationAttitudeRotation RateSupported DevicesiPhone 1iPhone 3GiPhone 3GSiPhone 4iPod Touch iPod Touch 4iPadAccelerometerYYYYYYYGyrosYiOS 4YYYYIf we mustYay!No.iPhone 4iPod Touch 4iPhone 3GSiPod TouchiPad w/ iOS 4iPhone 1iPad iOS 3.xClassesClassDescriptionCMMotionManagerThe GatewayCMAccelerometerDataAcceleration dataX, Y, and Z relative to deviceIn GsCMAttitudeOrientationRoll, Pitch, YawRotation MatrixQuaternionCMDeviceMotionRoll up of sensorsDifferentiates gravity from user accelerationCMGyroDataRotational VelocityCMLogItemTimestamped MeasurementParent Class for measurementsCMMotionManagerTells you whats availableisAvailableSets the update intervalssetUpdateIntervalStarts and stops updatesstartUpdatesstartUpdatesToQueue:withHandler:stopUpdatesLets you poll for updatesaccelerometerDatagyroDatadeviceMotion

CMMotionManagerCMMotionManager *mgr = [[CMMotionManager alloc] init];

Initializes reference frame at construction

Only make one of these for your appCore Motion Coordinate SystemQuick Reference

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

Measured in GsCMGyroDataYAGNI

Gyros have bias; DeviceMotion fusion algorithms remove this

Get orientation from DeviceMotion insteadCMDeviceMotionCMAttitude attitudeCMRotationRate rotationRate

CMAcceleration gravityCMAcceleration userAccelerationDEMOMacCMViewerCMIPViewer

Source code available:http://bitbucket.org/jblocksom/coremotionviewer

MacCMView: Whats Going On?Mac opens socket; iPhone connectsiPhone sends CM updates to MacMac uses rotation matrix for display

From CMAttitudeCMAttitudeRotation asYaw, Pitch, RollQuaternionRotation Matrix

multiplyByInverseOfAttitude: Why Quaternions?Great technique for representing rotationsMutiplying q1 and q2 is composing rotationsCan easily pull out axis / angleAvoids Gimbal Lock

http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotationis a pretty good treatmentGraphics Gems textbooksWikipedia rant great for Epipolar Geometry, terrible for Quaternions22multiplyByInverseOfAttitude:Teapot Demo revisitedCore Motion in SimulatorAccelerometer: Not availableGyros: Not availableDevice Motion: Not available

Workaround thoughts

Final Steps: App RequirementsAdd UIRequiredDeviceCapabilities foraccelerometergyro

Not needed for orientation / shake events

See Event Handling Guide,Setting Required Hardware Capabilities for Accelerometer and Gyroscope EventsExperimentsiPhone 3GS vs iPhone 4Intertial NavigatorSalad Spinner

Further ReadingEvent Handling Guide for iPhone OSLook under Motion EventsSection titled Core MotionCore Motion framework referenceSample CodeWWDC 10: CoreMotionTeapot

iPhone Sensor Group?