Frage

Erhalten Sie den darin enthaltenen Rotationsmatrixwert public static boolean getRotationMatrix (float[] R, float[] I, float[] gravity, float[] geomagnetic)Hier wie kann ich das berechnen? float[] gravity?Ich habe ein Codebeispiel gefunden, in dem das berechnet wird orientation beides nutzen Accelerometer Und Magnetic field

boolean success = SensorManager.getRotationMatrix(
   matrixR,
   matrixI,
   valuesAccelerometer,
   valuesMagneticField);

if(success){
SensorManager.getOrientation(matrixR, matrixValues);

double azimuth = Math.toDegrees(matrixValues[0]);
double pitch = Math.toDegrees(matrixValues[1]);
double roll = Math.toDegrees(matrixValues[2]);

readingAzimuth.setText("Azimuth: " + String.valueOf(azimuth));
readingPitch.setText("Pitch: " + String.valueOf(pitch));
 readingRoll.setText("Roll: "+String.valueOf(roll));
}

Meine Fragen sind:

  • Ist der Orientierungswert der Rotationsmatrixwert?
  • Wenn nein, wie kann ich dann diesen Code implementieren, um den Rotationsmatrixwert mithilfe von Magnetik zu erhalten?Feld?

Um die Rotationsmatrix zu erhalten, verwende ich diesen Code

 public void onSensorChanged(SensorEvent sensorEvent) {
    if (timestamp != 0) {
        final double dT = (sensorEvent.timestamp - timestamp) * NS2S;
            double magneticX = sensorEvent.values[0];
            double magneticY = sensorEvent.values[1];
            double magneticZ = sensorEvent.values[2];
                        double omegaMagnitude =Math.sqrt(magneticX*magneticX + magneticY*magneticY + magneticZ*magneticZ);

                        if (omegaMagnitude > EPSILON) {
                            magneticX /= omegaMagnitude;
                            magneticY /= omegaMagnitude;
                            magneticZ /= omegaMagnitude;
        }
                        double thetaOverTwo = omegaMagnitude * dT / 2.0f;
                        double sinThetaOverTwo =Math.sin(thetaOverTwo);
                        double cosThetaOverTwo = Math.cos(thetaOverTwo);
                        deltaRotationVector[0] = (double) (sinThetaOverTwo * magneticX);
                        deltaRotationVector[1] = (double) (sinThetaOverTwo * magneticY);
                        deltaRotationVector[2] = (double) (sinThetaOverTwo * magneticZ);
                        deltaRotationVector[3] = cosThetaOverTwo;


    }
     double[] deltaRotationMatrix = new double[9];
     SensorManager.getRotationMatrixFromVector(deltaRotationMatrix, deltaRotationVector);
}

Aber das Problem ist folgendes getRotationMatrixFromVector Hier steht „undefiniert“ für den Sensor. Irgendeine Idee?

War es hilfreich?

Lösung

Die Ausrichtung ist keine Rotationsmatrix, da sie nur Winkel in Bezug auf den magnetischen Norden liefert.Sie können die erhalten Rotationsmatrix (Richtungs-Kosinus-Matrix), die Ihnen dabei hilft, die Koordinaten Ihres Geräterahmens auf folgende Weise in den Erdrahmen umzuwandeln:

DCM from Wikipedia

mit

azimuth = Azimut (Bogenmaß)

pitch= Tonhöhe (Bogenmaß)

roll= rollen (Bogenmaß)

Andere Tipps

Ich weiß, dass dies ein alter Thread ist, aber falls es hilft: Für Android denke ich, dass die 3x3-Rotationsmatrix tatsächlich durch eine Variation der genehmigten Antwort gegeben ist.Genauer gesagt ist es in Android die Rotationsmatrix

     (cosφ cosψ - sinφ sinψ sinθ)     sinφ cosθ     ( cosφ sinψ + sinφ cosψ sinθ)
    -(sinφ cosψ + cosφ sinψ sinθ)     cosφ cosθ     (-sinφ sinψ + cosφ cosψ sinθ)
              -sinψ cosθ                 -sinθ                  cosφ cosθ

Wo

    φ = azimuth
    θ = pitch
    ψ = roll

was der 3x3 Android-Rotationsmatrix R[0] bis R[8] (matrixR in der Frage) über entspricht

    R[0] R[1] R[2]
    R[3] R[4] R[5]
    R[6] R[7] R[8]
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top