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

后端 未结 1 503
被撕碎了的回忆
被撕碎了的回忆 2021-01-14 06:16

I see that I can retrieve CMAttitude from a device and from it I can read 3 values which I need (pitch, roll and yaw). As I understand, this CMAttitude object is managed by

相关标签:
1条回答
  • 2021-01-14 07:06
    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:

    • "What's New in Core Motion" WWDC 2011 video,
    • "Sensing Device Motion in iOS 4" WWDC 2010 video

    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.

    0 讨论(0)
提交回复
热议问题