6

I don't have an iPhone 4 with me right now and I am trying to find a documentation that shows the ranges of yaw, pitch and roll and the correspondent positions of the device.

I know that the accelerometer varies from -1 to +1 but on my tests yesterday on my iPhone, showed me that the roll varies from -M_PI to +M_PI, but yaw and pitch ranges are half of that. Is this correct?

Where do I find documentation about these ranges? I don't see it on Apple vague docs.

Thanks.

Duck
  • 34,902
  • 47
  • 248
  • 470

2 Answers2

13

This is not a full answer, but in the interest of starting the ball rolling:

I'm assuming you are talking about the device attitude rather than the raw gyro data.

Anecdotally (I have an ipod touch 4 gen sitting in front of me displaying these values):

pitch: looks to be a range of -(M_PI/2) -> +(M_PI/2) although mine caps at ~ +1.55 / -1.51

roll: -M_PI -> +M_PI

yaw: -M_PI -> +M_PI

Just a note, at least on my device pitch doesn't differentiate tilt "forward" vs "backward", just gives the angle of the device relative to the direction of gravity. To figure out if the screen is pointed down or up, you can of course check gravity.z.

If you're using CMDeviceMotion there is a property called gravity on it, just grab gravity.z. It will be negative if the device's display is tilting upward (away from gravity) and positive if the display is facing down (toward gravity)

Note that the algorithms used by CMDeviceMotion are pretty good at separating gravity from user acceleration but under certain kinds of motion there may be some lag before the values become correct, I would love to here from someone with a better solution.

J.Spiral
  • 475
  • 5
  • 10
  • thanks and how do I check gravity? I mean, how do I use the information of the direction of gravity to expand pitch so it will be in the range -M_PI -> +M_PI ??? – Duck Feb 18 '11 at 10:57
  • Added a couple paragraphs at the end of my answer expanding on using the gravity direction. – J.Spiral Feb 18 '11 at 17:42
  • thanks!!!!!!!! I will check this out. I am trying to see if I can extract the rotation using quaternions... I think this has potential. My big question is why apple turns things so difficult? They like to create "elegant" solutions but the elegance hurts functionality many times and you have to always create turns and turns around stuff to get what is needed. Anyway, thanks! – Duck Feb 18 '11 at 18:03
  • Any updates on your solutions? I too am looking forward for a solution. Thanks! – Raj Pawan Gumdal Apr 24 '11 at 12:07
  • 1
    @DigitalRobot: The slight difficulty is not because "they want to make it elegant". It's because pitch, roll, and yaw partly overlap. For example, suppose that you want to raise the phone from a position flat on the table to a vertical landscape position. You can achieve that with a 90 degrees yaw followed by a 90 degrees roll. Or, you achieve the same effect with a 90 degree pitch followed by a 90 degrees yaw. In order to avoid these kind of ambiguities, it appears Apple has restricted the range of pitch. – fishinear Mar 30 '12 at 23:08
1

I have recently faced the same problem for an iOS app that counts the number of flips that the phone does. Apple has rejected it so I have published it on GitHub, may be useful for you:

Flip Your Phone! - https://github.com/apascual/flip-your-phone

I never thought on the solution using the gravity Z variable, I will try it soon and I come back with some updates.

apascual
  • 2,970
  • 1
  • 20
  • 32