Get pitch, roll and yaw relative to geographic north on iOS?

非 Y 不嫁゛ 提交于 2019-12-01 09:18:33
  1. and 2:

iOS 5.0 simplifies this task. CMMotion manager has new method:


- (void)startDeviceMotionUpdatesUsingReferenceFrame:(CMAttitudeReferenceFrame)referenceFrame

As reference frame you can use this values:

  • CMAttitudeReferenceFrameXMagneticNorthZVertical for magnetic north,
  • CMAttitudeReferenceFrameXTrueNorthZVertical for true north.

If you want to do this with older iOS im afraid you have to calibrate this by yourself using current user location.

Try checkout this resources:

3. If device has no gyro, the deviceMotionAvailable property of CMMotionManger will be "NO" (it is equivalent to gyroAvailable property) and you cannot get attitude using device motion. The only thing you can do is to read accelerometer and magnetometer data directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!