如何确定绝对方向

发布于 2024-07-29 02:52:33 字数 314 浏览 14 评论 0原文

我有一个 xyz 加速度计和磁力计。 现在我想使用两者来确定设备的方向。 我看到的问题是,根据设备方向,我需要以不同的顺序使用传感器。

让我举个例子。 如果设备面向我,则可以通过加速度计确定滚动和俯仰的变化。 对于偏航,我使用磁力计。

但是,如果我将设备水平放置(即将其旋转 90°,面向天花板),那么向上矢量(现在水平)的任何变化都不会被注意到,因为加速度计不会检测到任何变化。 现在可以用磁力计检测到这一点。

所以问题是,如何确定何时使用其中之一。 这对于两个传感器来说就足够了还是我还需要其他东西?

谢谢

I have a xyz accelerometer and magnetometer. Now I want to determine the orientation of the device using both. The problem I see is that depending on the device orientation, I'd need to use the sensors in different order.

Let me give an example. If I have the device facing me then changes in both the roll and pitch can be determined with the accelerometer. For yaw I use the magnetometer.

But if I put the device horizontally (ie. turn it 90º, facing the ceiling) then any change in the up vector (now horizontal) isn't notice, as the accelerometer doesn't detect any change. This can now be detected with the magnetometer.

So the question is, how to determine when to use one or the other. Is this enough with both sensors or do I need something else?

Thanks

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

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

发布评论

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

评论(5

薄荷梦 2024-08-05 02:52:34

关键是使用重力和磁力计这两个向量的叉积。 叉积给出了一个垂直于它们的新向量。 这意味着它是水平的(垂直于下方)并且与北方向成 90 度。 现在您有了定义方向的三个正交向量。 它有点难看,因为它们并不都是垂直的,但这很容易修复。 如果然后将此新向量与重力向量交叉,则会给出垂直于重力向量和磁体平面向量的第三个向量。 现在您有了三个垂直向量,它们定义了您的 3D 方向坐标系。 原始加速度计(重力)矢量定义 Z(上/下),两个叉积矢量定义方向的东/西和北/南分量。

The key is to use the cross product of the two vectors, gravity and magnetometer. The cross product gives a new vector perpendicular to them both. That means it is horizontal (perpendicular to down) and 90 degrees away from north. Now you have three orthogonal vectors which define orientation. It is a little ugly because they are not all perpendicular but that is easy to fix. If you then cross this new vector back with the gravity vector that gives a third vector perpendicular to the gravity vector and the magnet plane vector. Now you have three perpendicular vectors which defines your 3D orientation coordinate system. The original accelerometer (gravity) vector defines Z (up/down) and the two cross product vectors define the east/west and north/south components of the orientation.

指尖上得阳光 2024-08-05 02:52:34

这是一些介绍该项目的文档。 从其他答案可以清楚地看出,数学可能很棘手。
http://www.freescale.com/files/sensors/doc/app_note /AN4248.pdf

Here is some documentation that walks through this project. As is clear from other answers, the math can be tricky.
http://www.freescale.com/files/sensors/doc/app_note/AN4248.pdf

记忆之渊 2024-08-05 02:52:34

我认为“如何确定何时使用其中之一”的问题是误导的。 您应该始终使用两个传感器进行定位。 在某些情况下,其中之一是无用的。 然而,这些都是边缘情况。

I think the question "how to determine when to use one or the other" is misguided. You should always use both sensors for orientation. There are cases where one of them is useless. However, these are edge cases.

飘然心甜 2024-08-05 02:52:34

如果我理解正确,您将需要一些东西来根据基点(北、东、南和西)检测俯仰(倾斜)和方向。

可以从加速度计读取音调。

可以从指南针读取根据基点的方向。

将这两个传感器的输出与软件中的正确数学正确结合起来很可能会为您提供绝对方向。

我认为这样是可行的。

祝你好运。

If I understand you correctly, you'll need something to detect pitch (tilting) and orientation according to the cardinal points (North, East, South and West).

The pitch can be read from the accelerometer.

The orientation according to the cardinal points can be read from a compass.

Combining the output from these two sensors correctly with the right math in your software will most likely give you the absolute orientation.

I think it's doable that way.

Good luck.

清风疏影 2024-08-05 02:52:34

如果您仍然需要绝对方向,您可以查看 Adafruit 的此分线板:https://www.adafruit .com/products/2472。 该主板的优点在于它有一个 ARM Cortex-M0 处理器来为您完成所有计算。

In the event you still need absolute orientation you can check this break out board from Adafruit: https://www.adafruit.com/products/2472. The nice thing about this is board is that it has an ARM Cortex-M0 processor to do all of the calculations for you.

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