加速从设备的坐标系转换到绝对坐标系坐标系、设备

2023-09-12 11:00:15 作者:小脚裤。

这是我的Andr​​oid设备,我可以读取线性加速度值数组(该设备的坐标系中)和绝对定向值的数组(地球坐标系)。我需要的是获得后者的坐标线性加速度值。系统中。

From my Android device I can read an array of linear acceleration values (in the device's coordinate system) and an array of absolute orientation values (in Earth's coordinate system). What I need is to obtain the linear acceleration values in the latter coord. system.

我如何转换呢?

修改阿里在评论后答复:

好,所以如果我理解正确的话,当我测量线性加速度,手机的位置完全没有关系,因为读数是地球的坐标系中给出。对吧?

All right, so if I understand correctly, when I measure the linear acceleration, the position of the phone completely does not matter, because the readings are given in Earth's coordinate system. right?

不过,我只是做了一个测试,我把手机放在不同的位置,并获得加速度不同的轴。有3对图片 - 这是它们首次展示我是如何把设备(对不起,我画图技能大师),第二的人表示从由直线加提供的数据读数。传感器:

But I just did a test where I put the phone in different positions and got acceleration in different axes. There are 3 pairs of pictures - the first ones show how I put the device (sorry for my Paint "master skill") and the second ones show readings from data provided by the linear acc. sensor:

在设备放在左侧

在设备躺在回来

装置站立

和现在 - 为什么在第三种情况下的加速度发生沿Z轴(未Y)的,因为设备的位置没有关系

And now - why in the third case the acceleration occurs along the Z axis (not Y) since the device position doesn't matter?

推荐答案

我终于设法解决它!因此,要获得加速度矢量中的地球坐标系需要即可:

I finally managed to solve it! So to get acceleration vector in Earth's coordinate system you need to:

在得到旋转矩阵(浮动[16] 所以它可能是由 android.opengl.Matrix 以后使用的类)从 SensorManager.getRotationMatrix()(使用 SENSOR.TYPE_GRAVITY SENSOR.TYPE_MAGNETIC_FIELD 传感器值作为参数), 使用 android.opengl.Matrix.invertM()的旋转矩阵反转它(不转!) 使用 Sensor.TYPE_LINEAR_ACCELERATION 传感器获得的线性加速度矢量(在设备的坐标。SYS), 使用 android.opengl.Matrix.multiplyMV()来乘用线性加速度矢量旋转矩阵。 get rotation matrix (float[16] so it could be used later by android.opengl.Matrix class) from SensorManager.getRotationMatrix() (using SENSOR.TYPE_GRAVITY and SENSOR.TYPE_MAGNETIC_FIELD sensors values as parameters), use android.opengl.Matrix.invertM() on the rotation matrix to invert it (not transpose!), use Sensor.TYPE_LINEAR_ACCELERATION sensor to get linear acceleration vector (in device's coord. sys.), use android.opengl.Matrix.multiplyMV() to multiply the rotation matrix by linear acceleration vector.

和你有它!我希望我会节省一些precious的时间给别人。

And there you have it! I hope I will save some precious time for others.

感谢爱德华·法尔克和阿里提示​​!

Thanks for Edward Falk and Ali for hints!!

 
精彩推荐
图片推荐