获得全局坐标磁场值 [英] Getting magnetic field values in global coordinates

查看:263
本文介绍了获得全局坐标磁场值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关Android应用程序,我需要在全球(世界)坐标系的轴获得磁场测量。下面是我怎么回事(猜测)来实现这一点。请,如果必要的指正。此外,请注意,问题是有关任务算法的一部分,而不是关于Android的API传感器 - 我有后者的经验

For an Android application, I need to get magnetic field measurements across the axis of global (world's) coordinate system. Here is how I'm going (guessing) to implement this. Please, correct me if necessary. Also, please, note that the question is about algorithmic part of the task, and not about Android APIs for sensors - I have an experience with the latter.

第一步是获得 TYPE_MAGNETIC_FIELD 传感器数据( M )和 TYPE_ACCELEROMETER 传感器数据()。二是应该根据Android的文档中使用,但我不知道,如果它不应该是 TYPE_GRAVITY 而不是(同样),因为加速度似乎不提供纯净的重力。

First step is to obtain TYPE_MAGNETIC_FIELD sensor data (M) and TYPE_ACCELEROMETER sensor data (G). The second is supposed to be used according to Android's documentation, but I'm not sure if it shouldn't be TYPE_GRAVITY instead (again as G), because accelerometer seems providing not the pure gravity.

下一步是通过来获取旋转矩阵getRotationMatrix(R,I,G,M),其中研究 I 是旋转和倾斜矩阵水涨船高。

Next step is to get rotation matrices via getRotationMatrix(R, I, G, M), where R and I are rotation and inclination matrix correspondingly.

和现在去最questionnable部分:以 M 向量转换成世界坐标系中,我想乘 [R * I ] * M。

And now goes the most questionnable part: in order to convert M vector into the world's coordinate system, I suppose to multiply [R * I] * M.

我不知道这是一种把磁场读入的另一个依据的正确道路。另外,我不知道是否 remapCoordinateSystem 应使用的除了作为替代的上面的东西。

I'm not sure this is a correct way for transforming magnetic field reading into another basis. Also, I don't know if remapCoordinateSystem should be used in addition or as replacement for something above.

如果存在某个源$ C ​​$ C这已经这样做这件事情,我倒是AP preciate张贴链接,但我不想用大一般用途库(例如,用于增强现实支持)这个特定的任务,因为我想保持尽可能简单。

If there exists some source code which does this thing already, I'd appreciate posting a link, but I don't want to use big general purposes libraries (for example, for augmented reality support) for this specific task, because I'd like to keep it as simple as possible.

P.S。

我来到了主意,一些信息添加到原来的职位为清晰。

I came to the idea to add some information to the original post for clarity.

让我们假设将设备固定在桌子上,不断地从它的磁传感器读取数据。每个测量包含3个值,presenting磁场在轴线X,Y,Z,这是设备的本地坐标系。我认为,我可以忽略环境领域的波动(由低通滤波器平滑),因此这3个值应保持几乎相同的所有设备仍然存在的时间。如果我们围绕任何轴线旋转装置,值改变,因为我们改变了局部坐标系。但该字段本身实际上没有改变。所以,我想翻译本地X,Y,Z实地测量到这种X',Y',Z',他们保持各自的价值,无论到设备旋转,前提是设备不会从它的位置移动(只旋转)。

Let us suppose a device rests on a table and continuously reads data from its magnetic sensor. Each measurement contains 3 values, presenting magnetic field in axis X, Y, Z, which are device's local coordinate system. I take it that I can neglect environmental field fluctuations (smoothed by lowpass filter), so this 3 values should remain almost the same all the time the device remains in place. If we rotate device around any axis, the values change, because we change the local coordinate system. But the field itself is not actually changed. So I want to translate local X, Y, Z field measurements into such X', Y', Z', that they keep their respective values regardless to device rotation, provided that device is not moved from its location (only rotated).

我实现了上述算法和值X',Y'了定期和noticable变化,Z',通过建议转换获得,这样有什么不对的吧。

I've implemented the algorithm described above and got regular and noticable changes in values X', Y', Z', obtained through suggested transformations, so there is something wrong in it.

P.P.S。

有时我发现我的问题完全相同的副本在这里SO - <一个href=\"http://stackoverflow.com/questions/11772923/how-can-i-get-the-magnetic-field-vector-independent-of-the-device-rotation\">How我可以得到磁场矢量,独立于设备旋转 - ?但遗憾的是,答案中包含我的建议,并认为这一问题的任择议定书证实,他们不工作

Occasionally I've found an exact duplicate of my question here on SO - How can I get the magnetic field vector, independent of the device rotation? - but unfortunately the answer contains my suggestions, and OP of that question confirms that they do not work.

推荐答案

M的相对于世界坐标中的坐标就是乘法的研究* M

The coordinates of M with respect to the word coordinate is just the multiplication R*M.

的旋转矩阵R是数学基础矩阵的从设备的改变坐标到字坐标。
让我们的 X 以Z 是设备坐标基础和 W_1 W_2 W_3 待字坐标,然后依据结果
M = M_1的 X + M_2的 + m_3结果
而且结果
M = C_1 W_1 + C_2 W_2 + C_3 W_3 结果
其中,<强>研究 *(M_1,M_2,m_3)=(C_1,C_2,C_3)转。

The rotation matrix R is mathematically the change of basis matrix from the device coordinate to the word coordinate. Let X, Y, Z be the device coordinate basis and W_1, W_2, W_3 be the word coordinate basis then
M = m_1 X + m_2 Y + m_3
and also
M = c_1 W_1 + c_2 W_2 + c_3 W_3
where R * (m_1, m_2, m_3) = (c_1, c_2, c_3) transpose.

低通滤波器,仅用于在 X 路线来滤除加速度。 RemapCoordinateSystem用于改变的基础上,即从W_1,W_2,W_3到W_1,W_3,W_2改变顺序

Low pass filter is only used to filter out accelerations in the X, Y directions. RemapCoordinateSystem is used to change the order of the basis, ie changing from W_1, W_2, W_3 to W_1, W_3, W_2.

这篇关于获得全局坐标磁场值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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