我目前正在通過從我的手機接收定位數據來實現速度計。我使用恆定旋轉裝置 - 如何接收有效的定向數據?
SensorManager.getRotationMatrix(R, I, gravity, geomagnetic);
float orientation[] = new float[3];
SensorManager.getOrientation(R, orientation);
float azimuth = orientation[0];
double azimuthD = Math.toDegrees(azimuth);
if(azimuthD < 0) azimuthD = 360 + azimuthD;
有了這個,我能夠從我的手機收到旋轉數據,如方位等。 無論如何,當設備被放置在桌子或某事,這工作正常。但是,當圍繞某個點旋轉(在我的情況下,該設備固定在車輪上並以特定速度旋轉)時,這些值遠遠不準確。我相信,由於我正在使用重力和地磁傳感器,因此在旋轉時會與影響這些傳感器的力發生衝突。 As the wheel turns, the rotation changes relative to a point, but the local device rotation stays the same.
如何在設備轉動時訪問設備的方向而不會遇到大量嘈雜的數據? 我讀了一些關於Sensor.TYPE_ROTATION_VECTOR的屬性,但無法弄清楚它是如何工作的。此外,我還讀到了重新調整協調系統的可能性,但這應該如何提供幫助,因爲我的手機從未垂直於地面,更不像5°-10°的角度。 我將不勝感激任何幫助。
乾杯, viehlieb