加速度计重力组件

发布于 2024-09-04 10:45:13 字数 789 浏览 5 评论 0原文

我知道这个问题肯定已经在某个地方得到了多次解决,如果您知道它们的存在,请告诉我,谢谢。

快速概述: 我想从 3 轴加速度计计算这 3 个轴上每个轴上的重力分量。 我使用 2 轴自由体图来计算加速度计在世界 XZ、YZ 和 XY 轴上的重力分量。但该解决方案似乎略有偏差,对于只有 1 个加速度计轴暴露于重力的极端情况是可以接受的,但对于 45 度的俯仰和滚转,组合的总大小大于重力(通过 Xa^2+Ya^ 获得) 2+Za^2=g^2;Xa、Ya和Za是其X、Y和Z轴上的加速度计读数)。

更多细节: 该设备是 Nexus One,除了 3 轴加速度计之外,还具有用于方位角、俯仰角和横滚角的磁场传感器。

在世界轴上(Z 与重力方向相同,X 或 Y 指向北极,不认为这很重要吗?),我假设我的设备在 YZ 轴上有一个螺距 (P),以及 XZ 轴上的滚动 (R)。我用简单的三角函数得到: Sin(R)=Ax/Gxz Cos(R)=Az/Gxz Tan(R)=Ax/Az

还有另一组音高 P。

现在我将重力定义为在世界轴上有 3 个分量,一个仅在 XZ 轴上可测量的 Gxz,一个用于 YZ 的 Gyz,一个用于 YZ 的 Gxy。 XY 轴。 Gxz^2+Gyz^2+Gxy^2=2*G^2 2G 是因为这个定义中实际上包含了两次重力。

哦,XY 轴产生了一些更奇特的东西......如果需要的话我稍后会解释。

从这些方程中,我获得了 Az 的公式,并删除了 tan 运算,因为我不知道如何处理 tan90 计算(它是无穷大?)。

所以我的问题是,有人知道我这样做是对还是错,或者能够指出我正确的方向吗?

谢谢! DVD

I know this question is definitely solved somewhere many times already, please enlighten me if you know of their existence, thanks.

Quick rundown:
I want to compute from a 3 axis accelerometer the gravity component on each of these 3 axes.
I have used 2 axes free body diagrams to work out the accelerometer's gravity component in the world X-Z, Y-Z and X-Y axes. But the solution seems slightly off, it's acceptable for extreme cases when only 1 accelerometer axis is exposed to gravity, but for a pitch and roll of both 45 degrees, the combined total magnitude is greater than gravity (obtained by Xa^2+Ya^2+Za^2=g^2; Xa, Ya and Za are accelerometer readings in its X, Y and Z axis).

More detail:
The device is a Nexus One, and have a magnetic field sensor for azimuth, pitch and roll in addition to the 3-axis accelerometer.

In the world's axis (with Z in the same direction as gravity, and either X or Y points to the north pole, don't think this matters much?), I assumed my device has a pitch (P) on the Y-Z axis, and a roll (R) on the X-Z axis. With that I used simple trig to get:
Sin(R)=Ax/Gxz
Cos(R)=Az/Gxz
Tan(R)=Ax/Az

There is another set for pitch, P.

Now I defined gravity to have 3 components in the world's axis, a Gxz that is measurable only in the X-Z axis, a Gyz for Y-Z, and a Gxy for X-Y axis.
Gxz^2+Gyz^2+Gxy^2=2*G^2
the 2G is because gravity is effectively included twice in this definition.

Oh and the X-Y axis produce something more exotic... I'll explain if required later.

From these equations I obtained a formula for Az, and removed the tan operations because I don't know how to handle tan90 calculations (it's infinity?).

So my question is, anyone know whether I did this right/wrong or able to point me to the right direction?

Thanks!
Dvd

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

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

发布评论

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

评论(5

轮廓§ 2024-09-11 10:45:13

据我了解您的问题,您知道设备的俯仰和偏航(来自磁力计)并希望使用此信息来计算沿每个(设备)坐标轴的重力分量?

作为一名物理学家,我从小就使用欧拉角而不是俯仰-偏航-横滚,但看看 http://en.wikipedia.org/wiki/Yaw,_pitch,_and_roll 我将计算如下:
假设您的设备最初沿着全局坐标系定向,因此重力为 gvec:={0,0,-g}(在本地坐标系中)。现在我们必须在执行偏航-俯仰-滚动时计算 gvec 的局部坐标(偏航不会执行您提到的任何操作)。
对我来说,这对于旋转矩阵来说是最简单的:我们必须改变角度的符号,因为 gvec 保持不变。我将使用 Mathematica 执行此操作,因为那是我的锤子,这是钉子

yaw = RotationMatrix[-yawangle,{0,0,1}];
pitch = RotationMatrix[-pitchangle, {0,1,0}];
roll = RotationMatrix[-rollangle,{1,0,0}];
gvec={0,0,-g}
yaw.gvec
pitch.yaw.gvec
roll.pitch.yaw.gvec

输出是偏航之前以及偏航、俯仰和滚动之后的 gvec 的局部坐标(因此下面的最后一行应该是您的回答):

{0,0,-g}
{0,0,-g}
{g Sin[pitchangle],0,-g Cos[pitchangle]}
{g Sin[pitchangle],-g Cos[pitchangle] Sin[rollangle],-g Cos[pitchangle] Cos[rollangle]}

As I understand your question, you know the pitch and yaw of your device (from the magnetometer) and want to use this information to calculate the component of gravity along each of your (device) coordinate axes?

As a physicist I'm brought up with Euler angles instead of pitch-yaw-roll, but looking at http://en.wikipedia.org/wiki/Yaw,_pitch,_and_roll I would calculate this as follows:
Assume that your device is initially oriented along the global coordinate frame, so that gravity is gvec:={0,0,-g} (in the local frame). Now we have to calculate the local coordinates of gvec as we go through the yaw-pitch-roll (yaw doesn't do anything as you mention).
To me this is easiest with rotation matrices: we have to change the sign of the angles since gvec stays put. I'll do this with Mathematica because that's my hammer and this is a nail

yaw = RotationMatrix[-yawangle,{0,0,1}];
pitch = RotationMatrix[-pitchangle, {0,1,0}];
roll = RotationMatrix[-rollangle,{1,0,0}];
gvec={0,0,-g}
yaw.gvec
pitch.yaw.gvec
roll.pitch.yaw.gvec

The output is the local coordinates for gvec before yaw, and after yaw, pitch, and roll (so last line below should be your answer):

{0,0,-g}
{0,0,-g}
{g Sin[pitchangle],0,-g Cos[pitchangle]}
{g Sin[pitchangle],-g Cos[pitchangle] Sin[rollangle],-g Cos[pitchangle] Cos[rollangle]}
不及他 2024-09-11 10:45:13

我希望我知道,因为我也对这个问题感兴趣。

开始研究的好地方是 http://www.diydrones.com/ 。那边的人已经在飞机自动驾驶仪的背景下解决了这个问题。该网站链接了大量高质量的开源代码,以及所涉及数学的讨论。

I wish I knew because I am also interested in this problem.

A good place to start researching is at http://www.diydrones.com/ . The folks over there have already solved this problem in the context of aircraft autopilots. There is a ton of high quality, open source code linked to from that site, as well as discussions of the math involved.

顾铮苏瑾 2024-09-11 10:45:13

我意识到该帖子很旧,但以防万一其他人正在使用它:在您上次的回复中,您表明您仍然看到一些偏差,特别是在较大角度下。我也经历过同样的情况,但当我添加校准例程来捕获平坦表面上的加速度计读数并相对于平坦表面读数进行所有后续读数时,这种情况消失了。

I realize the posting is old but in case others are using it: In your last response you are indicating that you still see some deviation especially under larger angles. I experienced the same but it disappeared when I added a calibration routine to capture the accelerometer's reading on a flat surface and made all subsequent readings relative to the flat surface reading.

何其悲哀 2024-09-11 10:45:13

谢谢贾努斯!
你的解释让我对旋转矩阵有了启发。最后一行确实解决了我的问题!

现在我只需要重新设计我的自由体图来找出我做错了什么...我已经发现我不应该有重力的 XY 分量,因为重力与 XY 轴正交...

再次感谢!

编辑:跟进最后一行:
{g Sin[pitchangle],-g Cos[pitchangle] Sin[rollangle],-g Cos[pitchangle] Cos[rollangle]}

我发现而不是 -g Cos[pitchangle] Sin[rollangle]
我的自由体图中的 Sin[roll] 更接近实际的加速度。

我现在看不懂的是最后一个分量 -g Cos[pitchangle] Cos[rollangle]
现在它非常适合小俯仰角和横滚角,并且对于俯仰角或横滚角都可以正常工作,而另一个保持为 0,但是当俯仰角和横滚角都不再是小角度(例如 40 度)时,偏差就会变得很大。
实际上,我还意识到要在 Nexus 上实现 45 度滚动和 45 度俯仰,手机的 Z 轴读数将为 0,X 和 Y 的加速度均为 6.8 左右。
而 45 度横滚和 45 度俯仰的旋转矩阵乘法的结果公式将为 0.5 重力。

方向传感器输出是否有问题?或者这就是俯仰和滚动应该如何工作?

有谁知道如何解释这一点?

谢谢!

Thanks Janus!
Your explanation kinda enlightened me regarding the rotation matrix. And the final line did solve my problem!

Now I just need to rework my free body diagrams to find out what I've did wrong... I already found that I should not have had a X-Y component of gravity, since gravity is orthonormal to the X-Y axis...

THanks again!

Edit: follow up on this, the last line:
{g Sin[pitchangle],-g Cos[pitchangle] Sin[rollangle],-g Cos[pitchangle] Cos[rollangle]}

I've found instead of -g Cos[pitchangle] Sin[rollangle]
Sin[roll] from my free body diagram more closely resembles the actual acceleration.

What I can't understand now is the last component -g Cos[pitchangle] Cos[rollangle]
now it is perfect for small pitch and roll angles, and it works fine for either a pitch or roll angle while the other stays at 0, but a deviation becomes significant when both pitch and roll are no longer a small angle (say 40 degrees).
Actually I also realised to achieve a 45 roll and 45 pitch on the nexus one, the phone would have a 0 Z axis reading, with X and Y both on 6.8ish acceleration.
While the resulting formula from the rotation matrix multiplication at 45 roll and 45 pitch would be 0.5 gravity.

Is there something wrong with the orientation sensor output? or is this how pitch and roll are supposed to work?

Does anyone know how to account for this?

Thanks!

趴在窗边数星星i 2024-09-11 10:45:13

从加速度传感器获取重力矢量并不容易,您需要另一个传感器,如陀螺仪(如果有),才能从加速度计读数中获取正确的重力部分。

问候
航海家

It is not easy to get gravity vector from acceleration sensor, you need another sensor like gyro (if available) to get the correct gravity part from Accelerometer readings.

regards
Navigator

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