当我启动运动管理器时,手机基本上还在我手中,我得到了错误的态度值。为了获得旋转值,我使用了 CMAttitude 对象:
CMDeviceMotionHandler motionHandler = ^(CMDeviceMotion *motion, NSError *error) {
[self calculateNewPosition:motion];
_rotationMatrix = [self rotationToMat:[motion attitude].rotationMatrix];
};
[_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryZVertical toQueue:_motionQueue withHandler:motionHandler];
现在,我知道使用小型陀螺仪进行测量时存在噪声,并且重力矢量可能需要校准,但这似乎太过分了。0.5-1 秒后,旋转值从 0 变为超过 20°?!滚动、俯仰和偏航的两个示例:
-1.001736 22.637596 -0.197573
-0.095075 29.075712 -0.014112
如果是位置漂移,当我使用双重积分时,我会理解,但旋转直接来自传感器?
你知道为什么会这样吗?