Magnetometer for Compass on iPod Touch 4G

久未见 提交于 2019-12-12 02:16:32

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/10247167/magnetometer-for-compass-on-ipod-touch-4g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!