Search code examples
iosiphoneaccelerometerquaternionscore-motion

How to understand initial reference frame of iOS 8 device attitude?


In apple developer document about Event Handling Guide for iOS we can find a statement “Core Motion establishes the reference frame when your app starts device-motion updates”.

  1. Dose this means that when I start my app the first rotation data is my reference frame?
  2. If this is true, when I start my app with any attitude the first set of quaternion should be [1 0 0 0], is this right ?

Experiments about quaternion:

  1. I start my app with iphone flat on the table
    quaternion: [0.999 0.003 0.010 -0.004]
    accelerometer: [0.01 0.00 -1.00]
  2. I start my app with a tilt angle with X axis
    quaternion: [0.97 0.22 0.000 0.000]
    accelerometer: [0.00 -0.44 -0.89]

The experiment results does not fit with the statement in the document. I'm really confused about it.


Solution

  • You use the reference frame CMAttitudeReferenceFrameXArbitraryZVertical when you are interested in deviation from the initial position. In a reference frame of CMAttitudeReferenceFrameXArbitraryZVertical, the first attitude reported establishes the initial frame of reference. This means that its value is essentially arbitrary. You should ignore its value, but at the same time it is up to you to save this initial attitude and subsequently always to call multiplyByInverseOfAttitude: on any new attitudes, passing the saved attitude as parameter. This gives you information relative to the initial position.