Class

CMDeviceMotion

Encapsulated measurements of the attitude, rotation rate, and acceleration of a device.

Overview

An application receives or samples CMDeviceMotion objects at regular intervals after calling the startDeviceMotionUpdates(using:to:withHandler:) method, the startDeviceMotionUpdates(to:withHandler:) method, the startDeviceMotionUpdates(using:) method, or the startDeviceMotionUpdates() method of the CMMotionManager class.

The accelerometer measures the sum of two acceleration vectors: gravity and user acceleration. User acceleration is the acceleration that the user imparts to the device. Because Core Motion is able to track a device’s attitude using both the gyroscope and the accelerometer, it can differentiate between gravity and user acceleration. A CMDeviceMotion object provides both measurements in the gravity and userAcceleration properties.

Topics

Getting Attitude and Rotation Rate

var attitude: CMAttitude

The attitude of the device.

var rotationRate: CMRotationRate

The rotation rate of the device.

Getting Acceleration Data

var gravity: CMAcceleration

The gravity acceleration vector expressed in the device's reference frame.

var userAcceleration: CMAcceleration

The acceleration that the user is giving to the device.

Getting the Calibrated Magnetic Field

var magneticField: CMCalibratedMagneticField

Returns the magnetic field vector with respect to the device.

Getting the Heading

var heading: Double

The heading angle (measured in degrees) relative to the current reference frame.

Beta

Constants

struct CMCalibratedMagneticField

Calibrated magnetic field data and an estimate of the accuracy of the calibration.

enum CMMagneticFieldCalibrationAccuracy

Indicates the calibration accuracy of a magnetic field estimate

Relationships

Inherits From

See Also

Device Motion

Getting Processed Device Motion Data

Retrieve data that has already been processed to remove environmental bias, such as the effects of gravity.

class CMAttitude

The device’s attitude—its orientation relative to a known frame of reference—at a point in time.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software