0

When I start the motion manager, keeping the phone basically still in my hand, I get erroneous values for the attitude. To get the rotation value, I use the CMAttitude object:

CMDeviceMotionHandler motionHandler = ^(CMDeviceMotion *motion, NSError *error) {
    [self calculateNewPosition:motion];
    _rotationMatrix = [self rotationToMat:[motion attitude].rotationMatrix];
};

[_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryZVertical toQueue:_motionQueue withHandler:motionHandler];

Now, I know that there is noise in the measurements with tiny sized gyros, and the gravity vector probably needs calibration, but this seems to be too much off. After 0.5-1 seconds, the value of the rotations goes from 0 to over 20°?! Two examples for roll, pitch and yaw:

-1.001736 22.637596 -0.197573

-0.095075 29.075712 -0.014112

If it was the position drifting, when I use double integration, I would understand, but the rotation coming directly from the sensors?

Do you have any idea why this happens?

aledalgrande
  • 5,167
  • 3
  • 37
  • 65

1 Answers1

0

I just realized by seeing pictures in this question: Gyroscope on iPhone and testing out a bit more, that values are zero for a little while when starting the gyro, then, according to my configured coordinate frame (Z vertical), the values are adjusted to the current position of the phone.

So if I started with the phone in my hand at a 20° pitch, the value for pitch will be 0 for some small amount of time, then switch to 20°. Which means I have to wait for the rotation matrix to be non-zero to start tracking rotations.

Community
  • 1
  • 1
aledalgrande
  • 5,167
  • 3
  • 37
  • 65