改变传感器坐标android系统 [英] Changing sensor coordinate system in android

查看:318
本文介绍了改变传感器坐标android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android提供坐标系中的设备传感器的数据,无论它是如何导向。有没有什么办法在重力坐标系中的传感器数据?我的意思是不管该设备的方向如何我想加速度计数据和方向中的坐标系,其中y轴指向朝向朝向朝南极东部和z轴的天空,x轴。

Android provides sensor data in device coordinate system no matter how it is oriented. Is there any way to have sensor data in 'gravity' coordinate system? I mean no matter how the device is oriented I want accelerometer data and orientation in coordinate system where y-axis points toward the sky, x-axis toward the east and z-axis towards south pole.

我看了看 remapCoordinateSystem ,但似乎仅限于交换轴。我想为我的方向将不得不做一些低级别的旋转矩阵转换(或有没有更好的解决办法吗?)。但如何对加速度数据?有什么办法有数据有关的坐标系统,是固定的(有点世界坐标系)。

I took a look at remapCoordinateSystem but seems to be limited to only swapping axis. I guess for orientation I will have to do some low level rotation matrix transformation (or is there any better solution?). But how about acceleration data? Is there any way to have data in relation to coordinate system that is fixed (sort of world coordinate system).

我需要的,这是我想要做一些简单的运动姿势的时候手机在口袋里,它会更容易让我有相当的设备坐标系与用户坐标系统中的所有数据的原因(这将有有点不同的方向不同用户的口袋中)

The reason I need this is I'm trying to do some simple motion gestures when phone is in the pocket and it would be easier for me to have all data in coordinates system related to user rather device coordinate system (that will have a little bit different orientation in different user's pockets)

推荐答案

那么你基本上是在开始时获得北的方向 - 为此,你使用加速度计和磁场传感器来计算方向(或去precated方向传感器)。

Well you basically get the North orientation when starting - for this you use the accelerometer and the magnetic field sensor to compute orientation (or the deprecated Orientation sensor).

一旦你拥有它,你可以计算从这些方位角,俯仰和横滚角的旋转矩阵(方向余弦矩阵)。由矩阵相乘的加速度矢量将改变你的设备帧运动进入地球帧的。

Once you have it you can compute a rotation matrix (Direction Cosine Matrix) from those azimuth, pitch and roll angles. Multiplying your acceleration vector by that matrix will transform your device-frame movements into Earth-frame ones.

由于随着时间的推移您的设备将改变其方向,你需要更新它。要做到这一点,陀螺仪获取的数据,并更新你的方向余弦矩阵为每个新的价值。你也可以得到定向真正的价值,就像第一次,但它是不准确的。

As your device will change its orientation as time goes by, you'll need to update it. To do so, retrieve gyroscope's data and update your Direction Cosine Matrix for each new value. You could also get the orientation true value just like the first time, but it's less accurate.

我的解决方案包括DCM,但你也可以使用四元数,这只是一个选择的问题。随意如果需要多问。我希望这是你想知道什么!

My solution involves DCM, but you could also use quaternions, it's just a matter of choice. Feel free to ask more if needed. I hope this is what you wanted to know !

这篇关于改变传感器坐标android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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