基于磁力计和陀螺仪的寻北计算
我需要计算“面向”(无论它是基于真北还是磁北)。正如在 iOS 设备上所见,CLLocationManager
返回的 CLHeading
对象通过相应的属性为我们提供了真实航向和磁航向。另外,我们可以很容易地看到,这些值与设备的顶部(设备坐标系的正 Y 轴)相关,这不利于我的目的。
我实际上需要的是计算与设备屏幕相关的朝向(Z 轴),因为我不需要指南针,而是 AG 应用程序之王。问题是,当您将设备旋转到横向时,您会得到从您面向的方向向左或向右的航向值,这正是我最终需要的。 据我所知,我可以获得磁力计“原始”数据(以微特斯拉为单位,每个设备轴的值从 128 到 -128)以及陀螺仪“原始”数据(分为三种类型:欧拉天使、旋转矩阵或四元数)。我需要的是知道,我需要应用哪些计算来获得“面向”方向而不是“航向”。
I need to calculate "facing" (it doesn't matter if it will be based on true north or magnetic one). As it can be seen on the iOS devices the CLHeading
objects returned by the CLLocationManager
gives us both the true and the magnetic heading by corresponding properties. Also, we can very easily see, that those values are related to the top of the device (the positive Y axis of the devices coordinate system) which is not good for my purposes.
What I actually need is to calculate the facing related to the screen of the device (Z axis) as I don't need the compass, but a king of AG application. The issue is when you rotate the device to landscape you get heading values to the left or to the right from your facing direction, which is what I need in the end.
As I know, I can get the magnetometer "raw" data (given to me in microtesla units with values from 128 to -128 for each device axis) along with the gyroscope "raw" data ( which comes in three types: Euler angels, Rotation matrix or Quaternion). What I need is to know, which calculations I need to apply to those to get the "facing" direction instead of "heading".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不久前就做到了,因为我没有看到答案,所以我决定将我的解决方案放在这里,供那些将搜索同一问题答案的人......
这里有一些额外的片段,可能有助于理解这一点示例:
快乐编码...
I've made it a while ago and because I see no answers, I've decided to put my solution here for those who'll search answer for the same question...
And here are some additional snippets that may help to understand this example:
Happy coding...