C#中使用四元数表示陀螺仪角度

发布于 2024-10-06 16:58:54 字数 440 浏览 7 评论 0原文

我正在使用 WiiM+ 陀螺仪来计算旋转。

我对沿偏航轴、俯仰轴和横滚轴的转动速率进行积分,并将其存储在名为 angleSum 的向量中,

因此对于每个读数,angleSum(reading) 表示相对于初始方向的 y、p 和 r 旋转。

然后我使用四元数(我完全不熟悉)来表示如下:

q = Quaternion.createfromyawPitchRoll(angleSum.yaw,angleSum.pitch,angleSum.roll*(-1))

但是当我将 Wiimote 旋转 90 度时一个方向并打印出转弯的 qx、qy 和 qz,所有读数都受到转弯的影响(它们都显示 90 度转弯和返回,尽管其中两个的幅度较小)

我的问题非常基本:到底如何做我用这个四元数结构来表示方向?我需要在偏航、俯仰和滚动方面的绝对(或至少相对)方向。

谢谢!

I'm using the WiiM+ gyro to calculate rotation.

I integrate the rates of turn along the yaw, pitch and roll axes and store it in a vector called angleSum

So for each reading, angleSum(reading) represents the y, p and r rotations from the initial orientation.

I then use quaternions (which I'm totally unfamiliar with) to represent like this:

q = Quaternion.createfromyawPitchRoll(angleSum.yaw, angleSum.pitch, angleSum.roll*(-1))

But when I turn my wiimote 90 degrees in a direction and print out q.x, q.y and q.z for the turn, ALL readings are affected by the turn (they all show a 90 degree turn and back, although magnitude is smaller for two of them)

My question is very basic: how exactly do I use this quaternion structure to represent orientation? I need an absolute (or atleast relative) orientation in terms of yaw, pitch and roll.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

装纯掩盖桑 2024-10-13 16:58:54

四元数是一个四维结构,松散地定义为一个轴和一个旋转分量围绕定义的轴(通常表示为 {x, y, z, w})。看看您引用的方法,我假设您以弧度而不是度数提供偏航、俯仰和滚转。这将从表中消除最常见的实施错误。

假设您的实现是正确的(看起来是正确的),qxqyqz 都将随着任何旋转而发生预期的变化。请记住,您正在定义一个四维对象;四元数与欧拉角不同。

如果如果您想要以更人性化的欧拉表示法获得读数,请考虑将四元数转换回偏航、俯仰和滚动。 这里有关于在 XNA 中执行此操作的讨论

A quaternion is a four-dimensional construct loosely defined as an axis and a rotational component around the defined axis (usually represented as {x, y, z, w}). Having a look at the method you've referenced, I'll assume you're supplying yaw, pitch, and roll in radians instead of degrees. That'll remove the most common implementation mistake from the table.

Assuming your implementation is correct (and it seems to be), q.x, q.y, and q.z will all expectedly change with any rotation. Remember, you're defining a four-dimensional object; quaternions are not the same as Euler angles.

If you'd like to get a readout in more human-friendly Euler notation, consider converting your quaternion back into yaw, pitch, and roll. Here's a discussion for doing so in XNA.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文