从设备坐标系到绝对坐标系的加速度 [英] Acceleration from device's coordinate system into absolute coordinate system

查看:31
本文介绍了从设备坐标系到绝对坐标系的加速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我的 Android 设备中,我可以读取一组线性加速度值(在设备坐标系中)和一组绝对方向值(在地球坐标系中).我需要的是获得后一个坐标中的线性加速度值.系统.

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.

如何转换它们?

EDIT 在阿里回复评论后:

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

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:

  1. 设备放在左侧

  1. 设备仰卧

  1. 设备站立

现在 - 为什么在第三种情况下加速度沿 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:

  1. SensorManager.getRotationMatrix() 获取旋转矩阵(float[16] 以便稍后由 android.opengl.Matrix 类使用)code>(使用 SENSOR.TYPE_GRAVITYSENSOR.TYPE_MAGNETIC_FIELD 传感器值作为参数),
  2. 在旋转矩阵上使用 android.opengl.Matrix.invertM() 来反转它(不是转置!),
  3. 使用 Sensor.TYPE_LINEAR_ACCELERATION 传感器获得线性加速度矢量(在设备的坐标系中),
  4. 使用android.opengl.Matrix.multiplyMV()将旋转矩阵乘以线性加速度向量.
  1. 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),
  2. use android.opengl.Matrix.invertM() on the rotation matrix to invert it (not transpose!),
  3. use Sensor.TYPE_LINEAR_ACCELERATION sensor to get linear acceleration vector (in device's coord. sys.),
  4. use android.opengl.Matrix.multiplyMV() to multiply the rotation matrix by linear acceleration vector.

这就给你了!我希望我能为他人节省一些宝贵的时间.

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

感谢 Edward Falk 和 Ali 的提示!!

Thanks for Edward Falk and Ali for hints!!

这篇关于从设备坐标系到绝对坐标系的加速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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