3
votes

I see that I can retrieve CMAttitude from a device and from it I can read 3 values which I need (pitch, roll and yaw). As I understand, this CMAttitude object is managed by CoreMotion which is a Sensor Fusion manager for calculating correct results from compass, gyro and accelerometer together (on Android it is SensorManager Class).

So my questions are:

  1. Are those values (pitch, roll and yaw) relative to the magnetic north and gravity?

  2. If above is correct, how can I modify it to give me results relative to the geographic north?

  3. If a device (such as iPhone 3GS) doesn't have an gyroscope, do I have to tell it to Manager or can I just tell it to give me the device's attitude based on the sensors it has (acc + gyro + compas OR acc + compas)

1

1 Answers

6
votes
  1. and 2:

iOS 5.0 simplifies this task. CMMotion manager has new method:


- (void)startDeviceMotionUpdatesUsingReferenceFrame:(CMAttitudeReferenceFrame)referenceFrame

As reference frame you can use this values:

  • CMAttitudeReferenceFrameXMagneticNorthZVertical for magnetic north,
  • CMAttitudeReferenceFrameXTrueNorthZVertical for true north.

If you want to do this with older iOS im afraid you have to calibrate this by yourself using current user location.

Try checkout this resources:

3. If device has no gyro, the deviceMotionAvailable property of CMMotionManger will be "NO" (it is equivalent to gyroAvailable property) and you cannot get attitude using device motion. The only thing you can do is to read accelerometer and magnetometer data directly.