谁能告诉我重力传感器是否可以用作倾斜传感器以提高航向精度? [英] Can anyone tell me whether gravity sensor is as a tilt sensor to improve heading accuracy?

查看:308
本文介绍了谁能告诉我重力传感器是否可以用作倾斜传感器以提高航向精度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当电话与当地地面水平时,磁力仪的X和Y轴可用于计算北方的航向。但是在滚动或俯仰手机时,应使用俯仰和俯仰度来消除倾斜误差。



现在,我想知道重力传感器是否用作倾斜传感器以获取侧倾和俯仰角,以帮助提高向北行驶的精度吗?

解决方案

在这里,我描述了如何获取设备相对于水平面和磁北的方向。只需1行代码即可从方向(旋转矩阵)获得磁航向。



获取加速度计和磁力计的读数 a ,然后 m 作为3维向量。 a x m 跨产品指向东或西,而不管电话的方向如何。叉乘积是指向东方还是指向西方取决于您的符号约定(向上为正或负)和坐标系的惯用性(惯用左手或惯用右手)。



在计算之前,您可能希望至少对数据应用简单的移动平均值



通常,这不是一个好主意使用滚动,俯仰和偏航,所以请不要。无论如何,您都不需要它。



加速度计读数 a ,叉积 a x m ,加速度计读数的乘积与 a x( a x m )的乘积3个成对的垂直向量。通过将它们乘以它们各自长度的倒数,使它们成为单位矢量。这3个单位向量将为您提供旋转矩阵



旋转矩阵等于设备的方向。在我的应用中,磁航向为 atan2(R [Y] [Y] ,R [Y] [X])其中R是旋转矩阵。您可能必须采用旋转矩阵的不同元素,并可能更改符号,具体取决于您遵循的惯例。



如果设备的API提供了旋转矩阵,则它只是在代码行上获得了磁性标题。


X and Y axis of magnetometer can be used to calculate the heading of north when phone is level to the local ground. But when rolling or pitching the phone, we should use roll and pitch degree to eliminate the tilt error.

Now, I want to know whether the gravity sensor is used as tilt sensor to get the roll and pitch to help improve the accuracy of heading to the north?

解决方案

Here I describe how to get the orientation of the device with respect to the horizontal plane and the magnetic North. It is just 1 line of code to get the magnetic heading from the orientation (rotation matrix).

Take the accelerometer and magnetometer readings a and m as 3 dimensional vectors. The a x m cross-product points to either East or West regardless of the orientation of the phone. Whether the cross product points to East or West depends on your sign conventions (upwards is positive or negative) and the handedness of your coordinate system (left- or right-handed).

You might want to apply at least a simple moving average to your data before computing the cross-product.

In general, it is not a good idea to use roll, pitch and yaw, so please don't. Anyway, you do not need it.

The accelerometer reading a, the cross-product a x m, and the cross-product of accelerometer reading and the cross-product a x (a x m) gives you 3 pair-wise perpendicular vectors. Make them unit vectors by multiplying them with the reciprocal of their respective length. These 3 unit vectors will given you a rotation matrix.

The rotation matrix is equivalent to the orientation of the device. In my application, the magnetic heading was atan2(R[Y][Y], R[Y][X]) where R is the rotation matrix. You might have to take different elements of the rotation matrix and perhaps change signs, depending on the conventions you follow.

If the API of the device provides the rotation matrix then it is just on line of code to get the magnetic heading.

这篇关于谁能告诉我重力传感器是否可以用作倾斜传感器以提高航向精度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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