*The problem I am going to explain now has been always there as far as I know. Thus, I don't know whether this problem appeared some day, or has been there since its beginning, or has been fixed very recently while I haven't noticed. However, I highly suspect that the problem is still there from the beginning to now, and no one seems to be interested in addressing or fixing this issue while it is very annoying problem in practical use.
In Apple's API, Gyro data is represented in CMAttitude 3D Euler angle object, and this has 2 different representations, rotation matrix and quaternion. Mathematics proves that there shall be 2 singularities, north and south pole. Due to Apple's weird coordinate definition (Getting Raw Gyroscope Events | Apple Developer Documentation), those singularities happens at very annoying position: as far as I remember, it is upright position. Anyway, I remember that the position was in very frequent daily use area.
Now, when you want to measure relative rotation, you may use
- CMMotionManager.startDeviceMotionUpdates(using referenceFrame: CMAttitude
Reference Frame, ...)
- CMAttitude.multiply(by
Inverse Of: CMAttitude)