快速移动后漂移偏航角 [英] Drifting yaw angle after moving fast

查看:340
本文介绍了快速移动后漂移偏航角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我目前的项目中,我遇到了Core Motion的CMAttitude提供的四元数问题。我把iPhone 5(iOS 6.0.1)放在一个定义良好的起始位置。然后我开始快速移动设备,就像在快速起搏游戏中一样。当我在10-30秒后返回起始位置时,报告的偏航角与起始位置相差10-20度(大部分时间≈11°)。

In my current project I ran into trouble regarding the quaternion provided by Core Motion's CMAttitude. I put the iPhone 5 (iOS 6.0.1) at a well defined start position. Then I start to move the device quickly around like in a fast pacing game. When I return to the start position after 10-30 seconds the reported yaw angle differ from the start position for 10-20 degrees (most of the time ≈11°).

我使用旧的(可悲的是不再可用的)Core Motion Teapot样本来验证效果。用于记录的欧拉角直接从CMAttitude读取:

I used the old (and sadly no longer available) Core Motion Teapot sample to validate the effect. The Euler Angles for logging are read directly from CMAttitude:

        NSLog(@"pitch: %f, roll: %f, yaw: %f",  attitude.pitch * 180 / M_PI, attitude.roll * 180 / M_PI, attitude.yaw * 180 / M_PI);

我在不同工厂的不同时间制造的两台不同的iPhone 5设备上发现了这一点。但真的很奇怪的是,运行iOS 5.1.1的 iPhone 4正在按预期工作。在我看来,这是一个iOS错误,我已经提交了一个错误报告,但另一方面,我很难想象没有人偶然发现它。我怀疑它可能与重新设计的Core Motion API有关。从版本5开始,磁力计(罗盘)也被考虑用于传感器融合。控制台显示来自位置的偏差估计被提供给CoreMotion:

I found this on two different iPhone 5 devices manufactured at different times in different factories. But really weird is that my iPhone 4, running iOS 5.1.1, is working as expected. It seems to me an iOS bug and I filed a bug report already, but on the other hand I can hardly imagine that nobody had yet stumbled upon it. I suspect it might has to do with the redesigned Core Motion API. Starting with version 5 the magnetometer (compass) is considered for sensor fusion as well. Console shows that bias estimations from locationd are provided to CoreMotion:

locationd[41] <Notice>: GYTT inserted: bias,-0.196419,1.749323,-1.828088,variance,0.002644,0.004651,0.002527,temperature,31.554688

我的问题(s):使用Device Motion时是否有机会阻止磁力计读数?我尝试停用位置服务,但它不会影响Core Motion。如果不可能,替代/解决方法是什么,基于加速度计的重力估算?

My question(s): Is there chance to block magnetometer readings when using Device Motion? I tried deactivating location services but it doesn't affect Core Motion. If not possible, what is the alternative / workaround, Accelerometer based gravity estimation?

PS:由于我们正在处理基于四元数的模型,因此与Gimbal Lock相关

PS: As we are dealing with quaternion based models this is not related to Gimbal Lock

编辑:
在做了一些更多测量后,似乎很明显只有偏航受到影响。无论起始位置如何,俯仰和滚动显示偏差在公差范围内(<= 1°),而偏航是漂移的。 CMDeviceMotion.gravity 似乎也很干净。

编辑(2):
我可以使用附加到最新XCode版本的MotionGraphs示例重现该问题。偏航图可以重复地远离原点。

EDIT (2): I could reproduce the problem with the MotionGraphs sample attached to recent XCode versions. The yaw graph is reproducibly drifting away from origin.

推荐答案

不是最终的解决方案,但至少是我自己的问题的解决方法(我保留它作为未答复邀请你)。事实证明,至少 DeviceMotion.gravity 不受错误的影响。所以我决定重新设计这个非常简单的运动检测部分并使用 arcsin(gravity.x / || gravity ||)在倾斜时将主要角色移动到侧面设备。

Not the definitive solution but at least a workaround for my own question (I leave it as unanswered to invite you). It turned out that at least DeviceMotion.gravity is not affected by the bug. So I decided to redesign this pretty simple part of motion detection and use arcsin (gravity.x/||gravity||) for moving the main player character to the side when tilting the device.

这绝对是第二个最佳解决方案,因为它会破坏有关四元数中包含的完整旋转状态的信息。为了战略考虑,我决定采用这种方式:

This is definitely the second best solution as it destroys information about the full rotation status contained in a quaternion. I decided to it that way for strategical considerations:


  1. 我认为大多数开发人员都会使用重力矢量倾斜运动检测,而不是 CMAttitude.quaternion 因为大多数人对四元数数学并不感兴趣;-)因此,由于用户数量较多,因此在测试阶段可能会修复与重力向量相关的任何未来错误。

  2. 如果是软件错误并且与硬件问题无关,我认为,如果错误将尽快修复,仍有许多设备可能无法更新什么原因。因此潜在的未来客户遇到麻烦的风险很小但是> 0.所以第二个最好的解决方案有时可能是最好的。

  1. I think most developers do tilt motion detection with the gravity vector rather than CMAttitude.quaternion because most people are not that amused about quaternion maths ;-) Thus any future bugs related to the gravity vector will probably be fixed during the beta phase because of a larger number of users.
  2. If it is a software bug and not related to hardware issues, what I assume, and if the bug will be fixed ASAP, there is still a number of devices that might not get updated for what reason ever. Thus the risk that a potential future customer will run into trouble is small but > 0. So the second best solution might be sometimes the best.

这篇关于快速移动后漂移偏航角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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