【问题标题】:TYPE_ROTATION_VECTOR, TYPE_ORIENTATION give different results that too with deviationTYPE_ROTATION_VECTOR, TYPE_ORIENTATION 给出不同的结果,也有偏差
【发布时间】:2013-07-11 21:29:23
【问题描述】:

我已经为 Rotation Vector 和 Orientation Vector 实现了监听器,虽然我知道它已经贬值了,但我想同时测试它们。

我知道 Rotation Vector 是一种融合传感器并被推荐,但根据它,NORTH(getOrientation(rotationMatrix,value) 返回的 value[0] 轴承 0)与 NORTH 不匹配从方向传感器。 我还从 Playstore 的不同应用中统计,方向传感器的值似乎更接近它们。

而且很多次我的 Rotation_Vector 方位角值 [0] 然后 getOrientation 只是突然上升并保持在 -180 到 180 之间振荡

P.S "getRotationMatrix(float[] R, float[] I, float[] gravity, float[] geomagnetic)" 也给出与旋转向量相同的结果。

 public final void onSensorChanged(SensorEvent event)
{
   float rotationMatrix[];      
  switch(event.sensor.getType())
  {  
   .
       .
       .       
  case Sensor.TYPE_ROTATION_VECTOR:
       rotationMatrix=new float[16];
       mSensorManager.getRotationMatrixFromVector(rotationMatrix,event.values);
       determineOrientation(rotationMatrix);
       break; 

   case Sensor.TYPE_ORIENTATION:
        sensorZValue.setText(""+event.values[0]); //rotation about geographical z axis  
        sensorXValue.setText(""+event.values[1]); //rotation about geographical x axis  
        sensorYValue.setText(""+event.values[2]); //rotation about geographical y axis

 }//switch case ends
}


private void determineOrientation(float[] rotationMatrix)
    {
    float[] orientationValues = new float[3];
    SensorManager.getOrientation(rotationMatrix, orientationValues);
    double azimuth = Math.toDegrees(orientationValues[0]);
    double pitch = Math.toDegrees(orientationValues[1]);
    double roll = Math.toDegrees(orientationValues[2]);

    sensorZValue.setText(String.valueOf(azimuth));  //rotation about geographical z axis
    sensorXValue.setText(String.valueOf(pitch)); //rotation about geographical x axis   
    sensorYValue.setText(String.valueOf(roll)); //rotation about geographical y axis


    }

我想确定手机的 Y 轴和指向北方的向量之间的角度,这是我最初的实现。 请提出建议。

【问题讨论】:

  • 根据android文档值[1]指向北方。所以 - 节点指向北方,而不是方位角:-)

标签: android android-sensors magnetometer rotational-matrices digital-compass


【解决方案1】:

我认为这会有所帮助...

Android Compass that can Compensate for Tilt and Pitch

这会使用更可靠的来源计算北。

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2017-11-11
    • 2017-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 2016-09-17
    相关资源
    最近更新 更多