从陀螺仪数据中找到四元数?
我一直在尝试构建一个过滤器,可以成功地将指南针、地磁和陀螺仪数据结合起来,以产生流畅的增强现实体验。在阅读这篇文章以及大量讨论后,我终于找到了一个很好的算法更正我的传感器数据。我读过的大多数示例都展示了如何使用陀螺仪校正加速度计,但不展示如何使用陀螺仪校正指南针+加速度计数据。这是我已经确定的算法,它的效果很好,除了如果我不面向北而尝试查看场景时,我会遇到万向节锁定。该算法是Balance Filter,仅而不是仅在3D
初始化步骤中实现:
- 使用(嘈杂的)加速计和罗盘传感器数据初始化世界旋转矩阵(Android 已经提供了)
更新步骤:
集成每个轴 (x, y, z)
使用积分提供的欧拉角旋转世界旋转矩阵
从新旋转的矩阵中查找四元数
从未滤波的加速度计中查找旋转矩阵 +指南针数据(使用操作系统提供的函数,我认为它使用角度/轴计算)
- < p>从上一步生成的矩阵中获取四元数。
步骤 2 中生成的四元数(来自陀螺仪)和使用基于某些实验魔法的系数的加速度计数据之间的 Slerp
转换回矩阵并使用它来绘制场景。
我的问题是,当我面向北然后尝试向南看时,整个东西都会爆炸,并且看起来像是万向节锁。经过几次万向节锁定后,整个滤波器处于未定义状态。环顾四周,我听到每个人都说“只要使用四元数”,但恐怕事情没那么简单(至少对我来说),而且我知道我错过了一些东西。任何帮助将不胜感激。
I've been trying to build a filter that can successfully combine compass, geomagnetic, and gyroscopic data to produce a smooth augmented reality experience. After reading this post along with lots of discussions, I finally found out a good algorithm to correct my sensor data. Most examples I've read show how to correct accelerometers with gyroscopes, but not correct compass + accelerometer data with gyroscope. This is the algorithm I've settled upon, which works great except that I run into gimbal lock if I try to look at the scene if I'm not facing North. This algorithm is Balance Filter, only instead of only implemented in 3D
Initialization Step:
- Initialize a world rotation matrix using the (noisy) accelerometer and compass sensor data (this is provided by the Android already)
Update Steps:
Integrate the gyroscope reading (time_delta * reading) for each axis (x, y, z)
Rotate the world rotation matrix using the Euler angles supplied by the integration
Find the Quaternion from the newly rotated matrix
Find the rotation matrix from the unfiltered accelerometer + compass data (using the OS provided function, I think it uses angle/axis calculation)
Get the quaternion from the matrix generated in the previous step.
Slerp between quaternion generated in step 2 (from the gyroscope), and the accelerometer data using a coefficient based on some experimental magic
Convert back to a matrix and use that to draw the scene.
My problem is that when I'm facing North and then try to look south, the whole thing blows up and it appears to be gimbal lock. After a few gimbal locks, the whole filter is in an undefined state. Searching around I hear everybody saying "Just use Quaternions" but I'm afraid it's not that simple (at least not to me) and I know there's something I'm just missing. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果信息延迟或没有具体用处,但可能对其他人有用,因为我在一些研究后发现它:::
a。使用卡尔曼(线性或非线性)滤波器,您可以按照 ::
陀螺仪对增量角进行积分,同时加速度计告诉您外部限制。
b.欧拉速率与陀螺仪角度变化速率不同,因此您需要四元数或欧拉表示::
四元数并不简单,但两个主要步骤是 ----
当您循环遍历代码时,它会更新,因此只有四元数不是全局变量其余的
我只是想概述四元数实现的一般步骤。可能会有一些小错误,但我自己尝试过,它有效。请注意,当更改为欧拉角时,您将得到也称为“万向节锁”的奇点。
这里重要的一点是,这不是我的工作,但我在互联网上找到了它,并想感谢谁曾经做过这个无价的代码......干杯
Many appologies if information is delayed or not useful specifically but may be useful to others as I found it after some research:::
a. Using a kalman (linear or non linear) filter you do following ::
Gyro to integrate the delta angle while accelerometers tell you the outer limit.
b. Euler rates are different from Gyro rate of angle change so you ll need quaternion or Euler representation::
Quaternion is non trivial but two main steps are ----
As you loop through the code it gets updated so only quatenion is a global variables not the rest
I just wanted to outline general steps of quaternion implementation. There may be some minor errors but I tried this myself and it works. Please note that when changing to euler angles you will get singularities also called as "Gimbal lock"
An important note here is that this is not my work but I found it over the internet and wanted to thank who ever did this priceless code...Cheers
使用四元数的最大原因是为了避免欧拉角的奇点问题。您可以直接使用陀螺仪数据旋转四元数。
The biggest reason to use quaternions is to avoid the singularity problem with Euler angles. You can directly rotate a quaternion with gyro data.