从陀螺仪数据中查找四元数? [英] Finding a Quaternion from Gyroscope Data?

查看:716
本文介绍了从陀螺仪数据中查找四元数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试构建一个可以成功组合指南针,地磁和陀螺仪数据以产生平滑的增强现实体验的过滤器.在阅读这篇文章以及大量讨论之后,我终于找到了一个很好的算法更正我的传感器数据.我读过的大多数示例都显示了如何使用陀螺仪校正加速度计,但是没有使用陀螺仪校正指南针+加速度计数据.这是我已经确定的算法,该算法非常有效,但是如果我不面对北方时尝试看场景时会碰到万向节锁定.此算法是平衡过滤器,仅代替仅在3D中实现

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

初始化步骤:

  • 使用(嘈杂的)加速度计和指南针传感器数据初始化世界旋转矩阵(这已经由Android提供)

更新步骤:

  • 对每个轴(x,y,z)的陀螺仪读数(time_delta *读数)进行积分

  • 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

从未经过滤的加速度计+指南针数据中找到旋转矩阵(使用OS提供的功能,我认为它使用角度/轴计算)

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.

在第2步中生成的四元数(来自陀螺仪)和使用基于某种实验魔术的系数的加速度计数据之间的切换

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.

推荐答案

使用四元数的最大原因是为了避免Euler角的奇异性问题.您可以直接使用陀螺仪数据旋转四元数.

The biggest reason to use quaternions is to avoid the singularity problem with Euler angles. You can directly rotate a quaternion with gyro data.

这篇关于从陀螺仪数据中查找四元数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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