I have been trying to get heading values using the getOrientation() method.
boolean success = SensorManager.getRotationMatrix(rot, incl, accel, magnet);
if (success) {
// Compute orientation
float orientation[] = new float[3];
SensorManager.getOrientation(rot, orientation);
}
These values vary wildly, even if I keep the phone steady and walk with it in a steady position.
I then tried to change the reference of my acceleration values from the phone to the world axis:
// Compute world acceleration
float wAccel[] = new float[4];
float newAccel[] = new float[]{accel[0],accel[1],accel[2], 0};
android.opengl.Matrix.multiplyMV(wAccel, 0, rot, 0, newAccel, 0);
magnetLine += "W" + LOGSEPARATOR +
tsString + LOGSEPARATOR +
wAccel[0] + LOGSEPARATOR +
wAccel[1] + LOGSEPARATOR +
wAccel[2] + "\n";
}
I then used values from the X and Y axis on an atan2 function to determine the angle of the vector. Even if varying in a different manner, these values still display strange behavior (sometimes the value is constant, other times it displays a periodical behavior, as if following the footsteps).
I have seen some instances of people calling remapCoordinate system for situations somewhat similar to this. Is this what I am missing?