参考真北计算加速度 [英] calculate acceleration in reference to true north

查看:27
本文介绍了参考真北计算加速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的应用程序,我需要计算设备相对于真北的加速度.我的想法是计算设备相对于磁北的方向并将偏角应用于它以获得真北的方向.然后我想计算设备的加速度并将其引用到方向,但我不知道该怎么做.

For my App I need to calculate the acceleration of my device in reference to true north. My idea was to calculate the device orientation to magnetic north and apply the declination to it to get the orientation to true north. Then I want to calculate the acceleration of the device and reference it to the orientation, but I do not know how I should do this.

我会尝试使用 SensorManager.getRotationMatrix()SensorManager.getOrientation() 获取设备方向.然后我通过 GeomagneticField.getDeclination() 获得磁偏角,并将其应用于 SensorManager.getOrientation() 的方向值的方位角.

I would try to get the device orientation using SensorManager.getRotationMatrix() and SensorManager.getOrientation(). Then I get the declination by GeomagneticField.getDeclination()and apply it on the azimuth of the orientation values from SensorManager.getOrientation().

但是我如何将加速度计值映射到这个方向?甚至有可能吗?

But how do I map the accelerometer values to this orientation? Is it even possible?

推荐答案

加速度传感器返回设备的加速度.这是一个 3 维空间中的向量.该向量在设备坐标系中返回.你要的是这个向量在世界坐标中的坐标,简单来说就是

The accelerometer sensor returns the acceleration of the device. This is a vector in 3 dimentional space. This vector is returned in the device coordinate system. What you want is the coordinate of this vector in the world coordinate, which is simply

R = rotation matrix obtained by calling getRotationMatrix
A_D = accelerator vector return by sensor ( A_D = event.values.clone )
A_W = R * A_D is the same acceleration vector in the world coordinate system.

A_W is an array of dimention 3 
A_W[0] is acceleration due east.
A_W[1] is acceleration due north.

这是一些计算它的代码(假设 gravitymagnetic 包含来自各自传感器的输出):

Here is some code to compute it (assumes gravity and magnetic contain output from their respective sensors):

            float[] R = new float[9];
            float[] I = new float[9];
            SensorManager.getRotationMatrix(R, I, gravity, magnetic);
            float [] A_D = values.clone();
            float [] A_W = new float[3];
            A_W[0] = R[0] * A_D[0] + R[1] * A_D[1] + R[2] * A_D[2];
            A_W[1] = R[3] * A_D[0] + R[4] * A_D[1] + R[5] * A_D[2];
            A_W[2] = R[6] * A_D[0] + R[7] * A_D[1] + R[8] * A_D[2];

这篇关于参考真北计算加速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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