Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android加速-转换到用户坐标系_Android_Accelerometer_Android Sensors_Coordinate Systems_Coordinate Transformation - Fatal编程技术网

Android加速-转换到用户坐标系

Android加速-转换到用户坐标系,android,accelerometer,android-sensors,coordinate-systems,coordinate-transformation,Android,Accelerometer,Android Sensors,Coordinate Systems,Coordinate Transformation,当用户口袋里有手机时,我希望能够在用户坐标系中捕捉沿XYZ的加速度。我说用户坐标系有两个原因: 他们口袋中设备的方向应该无关紧要,不管方向如何,都应该给我相同的XYZ加速度值 相对于世界坐标系的行走方向应该无关紧要,所以从西到东行走和从东到西行走应该给我相同的数字 我的问题是,从基于设备的加速转换为基于用户的加速需要什么数学 我在这方面见过一个类似的线程:,但没有答案,而且我希望在没有校准阶段的情况下实现这一点(另一个线程允许) 我还看到了从设备坐标系转换到世界坐标系的线程: 我已通过以下方式实

当用户口袋里有手机时,我希望能够在用户坐标系中捕捉沿XYZ的加速度。我说用户坐标系有两个原因:

  • 他们口袋中设备的方向应该无关紧要,不管方向如何,都应该给我相同的XYZ加速度值
  • 相对于世界坐标系的行走方向应该无关紧要,所以从西到东行走和从东到西行走应该给我相同的数字
  • 我的问题是,从基于设备的加速转换为基于用户的加速需要什么数学

    我在这方面见过一个类似的线程:,但没有答案,而且我希望在没有校准阶段的情况下实现这一点(另一个线程允许)

    我还看到了从设备坐标系转换到世界坐标系的线程:

    我已通过以下方式实现了这一点:

    float[] accelerometerMatrix = new float[3];
    float[] accelerometerWorldMatrix = new float[3];
    float[] gravityMatrix = new float[3];
    float[] magneticMatrix = new float[3];
    float[] rotationMatrix = new float[9]; 
    
    <code to get and store the sensor values into the respective matrices>
    
    SensorManager.getRotationMatrix(rotationMatrix, null, gravityMatrix, magneticMatrix);
    
    accelerometerWorldMatrix[0] = rotationMatrix[0] * accelerometerMatrix[0] + rotationMatrix[1] * accelerometerMatrix[1] + rotationMatrix[2] * accelerometerMatrix[2];
    accelerometerWorldMatrix[1] = rotationMatrix[3] * accelerometerMatrix[0] + rotationMatrix[4] * accelerometerMatrix[1] + rotationMatrix[5] * accelerometerMatrix[2];
    accelerometerWorldMatrix[2] = rotationMatrix[6] * accelerometerMatrix[0] + rotationMatrix[7] * accelerometerMatrix[1] + rotationMatrix[8] * accelerometerMatrix[2];
    
    float[]加速度计矩阵=新的浮点[3];
    float[]加速度计世界矩阵=新的float[3];
    浮动[]重力矩阵=新浮动[3];
    浮动[]磁矩阵=新浮动[3];
    float[]旋转矩阵=新的float[9];
    <获取传感器值并将其存储到相应矩阵的代码>
    SensorManager.getRotationMatrix(rotationMatrix,null,gravityMatrix,magneticMatrix);
    加速度计世界矩阵[0]=旋转矩阵[0]*加速度计矩阵[0]+旋转矩阵[1]*加速度计矩阵[1]+旋转矩阵[2]*加速度计矩阵[2];
    加速度计世界矩阵[1]=旋转矩阵[3]*加速度计矩阵[0]+旋转矩阵[4]*加速度计矩阵[1]+旋转矩阵[5]*加速度计矩阵[2];
    加速度计世界矩阵[2]=旋转矩阵[6]*加速度计矩阵[0]+旋转矩阵[7]*加速度计矩阵[1]+旋转矩阵[8]*加速度计矩阵[2];
    
    该代码,虽然它的工作原理,但将加速度计XYZ值放在世界空间中。现在我需要从这一点进入用户空间

    最终,当用户向前行走时,我希望能够获得该加速度值,而不考虑1)他们行走的方向,以及2)设备在他们口袋中的方位。在上面的代码中,当用户朝东北方向向前行走时,XYZ值将不同于他们朝西南方向行走时的XYZ值,在我看来,XYZ值必须相同,因为用户仍在“向前”移动


    有没有办法做到这一点?我会考虑一个校准阶段的答案,但理想的是,我想跳过任何校准阶段,对于这个

    什么是用户坐标系统?@ HohanGuyon例如,如果用户向前走,加速度总是在+X中,不管手机方向和世界/罗盘航向都在。如果他们向左走,例如,它将始终是+Z。所以,一切都是相对于用户的,不管手机是如何定位的,或者他们的指南针方向是什么,都毫无意义,在什么的左边?用户总是向前走,不是吗?@HoanNguyen举个例子,如果他们向左走一步。即使用户向前移动,当他们从一个观察者身边走过时,他们的臀部仍然可能会发生侧摆,而这个观察者此时正在观察用户,用户正在向他移动。我知道你的目标。单靠加速计是不行的。