我正在使用像这样的旋转矢量传感器:
val sensor = sensorManager.getDefaultSensor(TYPE_ROTATION_VECTOR)
我在上面注册了SensorEventListener
:
private class OrientationListener : SensorEventListener {
private val rotationMatrix = FloatArray(9)
override fun onSensorChanged(event: SensorEvent) {
if (event.sensor.type != TYPE_ROTATION_VECTOR) return
SensorManager.getRotationMatrixFromVector(rotationMatrix, event.values)
val easting = rotationMatrix[0]
val northing = rotationMatrix[3]
val azimuth = -atan2(northing, easting)
val azimuthAccuracy = event.accuracy
debug { "Azimuth changed to ${azimuth}, accuracy ${azimuthAccuracy}" }
}
}
override fun onAccuracyChanged(sensor: Sensor, accuracy: Int) {
if (sensor.type == TYPE_ROTATION_VECTOR) {
info { "Azimuth accuracy changed to $accuracy" }
}
}
}
我什至从未观察到此代码报告过SENSOR_STATUS_ACCURACY_HIGH
之外的任何内容,即使在明显错误的时候(例如在车内)。然而,在这些情况下,谷歌地图和其他应用程序的准确性较低。
其他哪些应用程序还用于查找指南针方向的实际精度?