Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone compass presents the wrong heading pitch angle is > about 45°

This might be hard to explain the geometry so I will be careful in spelling it out. This is visible in the standard compas app and from the data in CLLocationManager.

1) When holding the phone in portrait orientation, consider the pitch angle to be 0°

2) When pointing the camera up into the sky (such as taking a picture of a cloud) the pitch angle goes from 0° -> 90° where 90 degrees is straight up.

3) when the phone is tilted upward (> 0 degrees and rotating on the "X" magnetometer axis) and when the phone is at about (but not exactly) 45 degrees, the compass heading rotates 180 degrees. So while the camera is still point "N", the compass will report "S".

4) for the next (roughly) 90 degrees, the compass heading is rotated 180 degrees.

This rotation of the heading is destructive for me and it does not align perfectly with the accelerometers. Is there a good tutorial (I did not find one off the bat) on using the the RAW data (X, Y, Z) from the CLHeading data to calculate heading data?

The end result is I want the heading of the compass to always match the heading of the camera.

like image 466
Steven Noyes Avatar asked Oct 12 '11 14:10

Steven Noyes


1 Answers

You can't rely on solely the compass heading. See this answer for what you're looking for, and in particular the CMAttitude object's yaw property to compensate for the pitch angle you're talking about: Compensating compass lag with the gyroscope on iPhone 4

like image 56
Duncan Babbage Avatar answered Oct 14 '22 21:10

Duncan Babbage