iPod Touch 4G上的指南针磁力仪 [英] Magnetometer for Compass on iPod Touch 4G

查看:127
本文介绍了iPod Touch 4G上的指南针磁力仪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道无法从iPod Touch 4G上的CoreLocation框架获取磁航向读数,但是可以使用CoreMotion框架生成磁强计读数.

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.

我也理解我需要使用CMMotionManager并设置deviceMotionUpdateInterval来实现此目的.然后,我可以使用- (void)startMagnetometerUpdates- (void)stopMagnetometerUpdates尊重和支持开始和停止更新.

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.

现在我有了原始的磁力计数据(x,y,z),如何使用它来实现磁航向?

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.

编辑:我的错误,无法在iPod Touch 4G上获得磁力计读数.

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

推荐答案

iPod touch没有磁力计(请参阅

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

也来自 CMMotionManager类参考(我的重点)

CMMotionManager对象是运动服务的网关 由iOS提供.这些服务为应用程序提供了 加速度计数据,转速数据,磁力计数据等 设备运动数据(例如姿态).这些类型的数据起源 使用设备的加速度计和(某些型号) 和陀螺仪.

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.

您看到的是iPod touch确实具有的来自其他传感器的运动数据.

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

这篇关于iPod Touch 4G上的指南针磁力仪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆