문제

I understand that it is not possible to get magnetic heading readings from the CoreLocation framework on an iPod Touch 4G, but it is possible to produce magnetometer readings using the CoreMotion framework.

I also understand that I need to use CMMotionManager and set the deviceMotionUpdateInterval to achieve this. I can then start and stop the updates with - (void)startMagnetometerUpdates and - (void)stopMagnetometerUpdates respectivley.

Now that I have my raw magnetometer data (x,y,z), how can I use it to achieve a magnetic heading?

I've seen some pretty complicated explanations online but would appreciate a code like example.

EDIT: My mistake, it is not possible to get magnetometer readings on the iPod Touch 4G.

도움이 되었습니까?

해결책

The iPod touch does not have a magnetometer (See apple-devices-with-magnetometer), so whatever you are calling magnetometer data cannot be magnetometer data.

Also from CMMotionManager Class Reference (my emphasis)

A CMMotionManager object is the gateway to the motion services provided by iOS. These services provide an application with accelerometer data, rotation-rate data, magnetometer data, and other device-motion data such as attitude. These types of data originate with a device’s accelerometers and (on some models) its magnetometer and gyroscope.

So you won't be able to produce a magnetic heading.

What you are seeing is motion data from the other sensors that the iPod touch does have.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top