Open
Description
Thank you for this WONDERFUL lib.
but the "roll" algorithm in the dmpGetYawPitchRoll should be
data[2] = atan2(gravity -> y , gravity -> z);
(at least one of the pitch or roll should be as simple as that, and only one uses sqrt)
see complete derivation
https://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf
about extending pitch and roll from degenerate -9090 to non degenerate -180180
i simply used the code below.
uint8_t MPU6050::dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity) {
// yaw: (about Z axis)
data[0] = atan2(2*q -> x*q -> y - 2*q -> w*q -> z, 2*q -> w*q -> w + 2*q -> x*q -> x - 1);
//pitch
data[1] = atan2(gravity -> x , sqrt(gravity -> y*gravity -> y + gravity -> z*gravity -> z));
//roll
data[2] = atan2(gravity -> y , gravity -> z);
if(gravity->z<0)
{
if(data[1]>0)
{ data[1] = 3.1415926 - data[1] ; }
else { data[1] = -3.1415926 - data[1] ; }
}
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels