Search code examples
iosxcodecore-motioncmattitude

Absolute yaw on iOS device


I want to now rotation delta of two devices. I try to use CMDeviceMotion's attitude.yaw.

let motionManager = CMMotionManager();
motionManager.showsDeviceMovementDisplay = true
motionManager.deviceMotionUpdateInterval = 1 / 25
if motionManager.deviceMotionAvailable {
   motionManager.startDeviceMotionUpdatesUsingReferenceFrame(CMAttitudeReferenceFrameXMagneticNorthZVertical,
   toQueue: NSOperationQueue.mainQueue(),
   withHandler: { (m: CMDeviceMotion!, e: NSError!) -> Void in
      if (e == nil) {
         self.attitude = m.attitud
         self.deviceAtitudeUpdated()
      }
   })
}

But when I run app on two devices and put them flush I expect to see the same value. But values are different. What should I do to see same values (maybe with little difference)


Solution

  • After trying different options I stay on using magneticField data instead of yaw. magneticField have some differences depends on device but amount of error is low.