CMDeviceMotion的所有属性是什么?

时间:2015-08-31 18:31:40

标签: objective-c accelerometer gyroscope cmmotionmanager

查看我可以从CMDeviceMotion获得的所有数据,我试图弄清楚所有这些数据点之间的差异。以下是否准确? 加速是我在各个方向上移动的速度。 陀螺仪/姿态是我在各个方向倾斜的程度。 态度就是俯仰和偏航。

那么我得到的这些引力数是多少? 旋转速度与我得到的态度数据有何不同?旋转速率是陀螺仪数据的衍生物还是什么?

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);
        }];
    }

输出:

>> 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

0 个答案:

没有答案