简体   繁体   中英

Pitch, roll and yaw from accelerometer and magnetometer

I would like to do some work based on the rotation vector. The problem is that the most of Android devices have not the gyroscope sensor (nor the rotation vector sensor). I think there is a way for calculating an approximation of the quaternion by using the accelerometer (for pitch and roll) and the magnetometer (for yaw). The problem is that their values are not limited by a maximum value (for pitch and roll I could use G=9.81 and try to filter the additional acceleration).

May someone help me to find an approximated solution?

float[] rotationMatrix = new float[16];
float[] rotationMatrixRemapped = new float[16];
float[] accMagOrientation = new float[3];

SensorManager.getRotationMatrix(rotationMatrix, null, oldAccelerometerVals, oldMagnetometerVals);
SensorManager.remapCoordinateSystem(rotationMatrix, SensorManager.AXIS_MINUS_Y, SensorManager.AXIS_MINUS_X, rotationMatrixRemapped);
SensorManager.getOrientation(rotationMatrix, accMagOrientation);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM