With iOS5 the update frequencey of the Compass raw data reading, CLHeading
, dropped dramatically. This rendered my augmented reality app unusable, because it depends on a close-to-real-time reading of the raw compass data.
Therefore I'm now trying to switch to CoreMotion. This provides more frequently updated magnetometer data:
cmManager = [[CMMotionManager alloc] init];
[cmManager startMagnetometerUpdates];
I can then access the magneticField
data anytime I want during the game:
CMMagneticField magneticField = cmManager.magnetometerData.magneticField;
The problem I have is the following:
The data in CMMagneticField
are in a different unit then CLHeading
x/y/z data.
I would like to convert the CMMagneticField
x/y/z data to the same units as CLHeading / CLHeadingComponentValue are - in order to be able to use my existing AR code.
Here a few readings:
7.3 / 17.64 / -39.58 CLHeadingComponentValue X/Y/Z
-103.12 / 88.51 / -20.05 CMMagneticField
-10.81 / -34.9 / -18.6 CLHeadingComponentValue X/Y/Z
-121.00 / 33.29 / 3.1 CMMagneticField
-20.8 / -38.0 / -4.0 CLHeadingComponentValue X/Y/Z
-132.9 / 32.2 / 14.4 CMMagneticField