The correct way to use ONLY the gyroscope and accelerometer to obtain a reliable current angle on any axis on ANDROID

A week ago, I did not know anything about Android Motion Sensors. Having learned an amazing thing called "Virtual Reality", I started looking for what sensors are used to obtain these results. Than I had an idea for APP, but I still don’t know which sensors I should use for the situation below:

I need to get the orientation of the phone in relation to myself. I mean, I have to be able to isolate each axis in degradation. Something like that:

enter image description here

, , , Z. , , : .

: http://www.thousand-thoughts.com/articles/#articles

, , , , ( , ).

, 0 - 360 , ?

(, . )

+4
1

, Z- Z 0. ( ). Z, , . (* "-", "+" )

float[] mGravity;
float[] mGeomagnetic;


    float[] temp = new float[9];
    float[] RR = new float[9];
    //Load rotation matrix into R
    SensorManager.getRotationMatrix(temp, null,
            mGravity, mGeomagnetic);

    //Remap to camera point-of-view
    SensorManager.remapCoordinateSystem(temp,
            SensorManager.AXIS_X,
            SensorManager.AXIS_Z, RR);

    //Return the orientation values
    float[] values = new float[3];
    SensorManager.getOrientation(RR, values);

    Double degrees = (values[2] * 180) / Math.PI;
+1

Source: https://habr.com/ru/post/1584947/


All Articles