【问题标题】:Unreliable Gyroscope values after Calibration校准后陀螺仪值不可靠
【发布时间】:2013-09-06 16:44:51
【问题描述】:

我已经实现了一个包含以下传感器的应用程序:

  • 加速度计
  • 磁场
  • 方向(已弃用)
  • 陀螺仪
  • 重力

这是 onSensorChanged() 方法的示例代码:

        @Override
    public void onSensorChanged(SensorEvent event) {
        int type = event.sensor.getType();

        if (event.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
            if (type == Sensor.TYPE_GYROSCOPE) {
                // Log.e(TAG, "Unreliable gyroscope");
            } else if (type == Sensor.TYPE_GRAVITY) {
                // Log.e(TAG, "Unreliable gravity");
            }
            return;
        }

        if (type == Sensor.TYPE_ACCELEROMETER) {
            mmAcceleration = event.values.clone();
        } else if (type == Sensor.TYPE_MAGNETIC_FIELD) {
            mmGeomagnetic = event.values.clone();
        } else if (type == Sensor.TYPE_GYROSCOPE) {
            mmRotation = event.values.clone();
        } else if (type == Sensor.TYPE_ORIENTATION) {
            mmOrientation = event.values.clone();
        } else if (type == Sensor.TYPE_GRAVITY) {
            mmGravity = event.values.clone();
        }

        if (mmAcceleration != null && mmGeomagnetic != null
                && mmOrientation != null) {

                            // Handling the data ...

            mmAcceleration = null;
            mmGeomagnetic = null;
            mmRotation = null;
            mmOrientation = null;
            mmGravity = null;
        }
    }

我尝试过代码的设备是 HTC One S。我已经在 3 个独立的设备上尝试过。此外,我已经多次校准 G 传感器,然后启动了应用程序,但我仍然得到不可靠的结果。我也尝试过校准,重新启动手机然后再次校准,甚至在重新启动后直接运行我的应用程序。其他传感器工作正常。我也尝试过不同的环境(室内),我没有靠近任何干扰源。

我仍然得到不可靠的 (SENSOR_STATUS_UNRELIABLE) 陀螺仪和重力结果(使用陀螺仪)传感器。

您对可能出现的问题有什么建议吗?

提前谢谢你。

【问题讨论】:

  • 感谢您的链接,我知道这项工作。我的问题是陀螺仪和重力传感器的 event.accuracy == SENSOR_STATUS_UNRELIABLE,而不是传感器融合。
  • 我假设你已经读过:stackoverflow.com/questions/6256256/… 我刚刚意识到这是用于指南针而不是重力/陀螺仪。
  • 您获取传感器数据的频率是多少?
  • 我将 SENSOR_DELAY_NORMAL 用于陀螺仪,将 SENSOR_DELAY_GAME 用于重力传感器。

标签: android accelerometer android-sensors gyroscope


【解决方案1】:

我认为您可能想要对加速度计数据和陀螺仪数据应用“互补滤波器”或“卡尔曼滤波器”......这应该可以解决问题......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多