在iOS上相对于地理北方获得俯仰,翻滚和偏航? [英] Get pitch, roll and yaw relative to geographic north on iOS?

查看:228
本文介绍了在iOS上相对于地理北方获得俯仰,翻滚和偏航?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现我可以检索 CMAttitude 来自设备我可以读取我需要的3个值(俯仰,滚动和偏航)。
据我所知,这个CMAttitude对象由CoreMotion管理,CoreMotion是一个传感器融合管理器,用于计算罗盘,陀螺仪和加速度计的正确结果(在Android上它是SensorManager类)。



所以我的问题是:


  1. 这些值(音高,滚动)和偏航相对于磁北和重力?


  2. 如果以上是正确的,我如何修改它以给我相对于地理北方的结果? / p>


  3. 如果设备(如iPhone 3GS)没有陀螺仪,我是否必须告诉经理或者我可以告诉它给我该设备基于其所具有的传感器的态度( acc + gyro + compas OR acc + compas



解决方案


  1. 和2:

iOS 5.0简化了这项任务。 CMMotion经理有新的方法:

  
- (void)startDeviceMotionUpdatesUsingReferenceFrame:(CMAttitudeReferenceFrame)referenceFrame

作为参考框架,您可以使用以下值:




  • CMAttitudeReferenceFrameXMagneticNorthZVertical for magnetic north,

  • CMAttitudeReferenceFrameXTrueNorthZVertical for true north。



如果你想要使用旧的iOS进行此操作,我担心您必须使用当前用户位置自行校准。



尝试结帐此资源:





3。
如果设备没有陀螺仪,CMMotionManger的deviceMotionAvailable属性将为NO(它相当于gyroAvailable属性),你无法使用设备运动获得态度。您唯一能做的就是直接读取加速度计和磁力计数据。


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. 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.

这篇关于在iOS上相对于地理北方获得俯仰,翻滚和偏航?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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