2

Looking at all the data I can get from a CMDeviceMotion, I'm trying to make sense of the difference between all of these data points. Is it accurate to say that the following? Acceleration is how fast I am moving in the various directions. Gyroscope/Attitude is how much I am tilted in the various directions. And attitude is the pitch roll and yaw.

So what are these gravity numbers that I am getting? And how does the rotation rate differ from the attitude data that I am getting? Is the rotation rate the derivative of the the gyro data or something?

self.motionManager = [CMMotionManager new];
[self.motionManager setAccelerometerUpdateInterval:.01];

if (self.motionManager.deviceMotionAvailable) {
        [self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) {
            NSLog(@"attitude: %@", motion.attitude);
            NSLog(@"rotationrate x: %f", motion.rotationRate.x);
            NSLog(@"rotationrate y: %f", motion.rotationRate.y);
            NSLog(@"rotationrate z: %f", motion.rotationRate.z);
            NSLog(@"gravity x: %f", motion.gravity.x);
            NSLog(@"gravity y: %f", motion.gravity.y);
            NSLog(@"gravity z: %f", motion.gravity.z);
            NSLog(@"acc x: %f", motion.userAcceleration.x);
            NSLog(@"acc y: %f", motion.userAcceleration.y);
            NSLog(@"acc z: %f", motion.userAcceleration.z);
        }];
    }

Output:

>> rotationrate x: 0.002171
>> rotationrate y: -0.000725
>> rotationrate z: -0.000747
>> gravity x: -0.002035
>> gravity y: -0.094994
>> gravity z: -0.995476
>> acc x: -0.001200
>> acc y: -0.000297
>> acc z: -0.009560
>> attitude: CMAttitude Pitch: 5.450850, Roll: -0.117074, Yaw: -0.044748
Chase Roberts
  • 9,082
  • 13
  • 73
  • 131

0 Answers0