0

I am using Jeff library to get Rotational data from the MPU6050. but there is a problem ! Jeff lib

Jeff codes made 0 to 360 degree output. that's mean we don't have 361 degree! and more. in my project I need freely rotational. for example 800 degree or -1250 degree....

I guess this part of library must be changed :

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: (nose up/down, about Y axis)
    data[1] = atan(gravity -> x / sqrt(gravity -> y*gravity -> y + gravity -> z*gravity -> z));
    // roll: (tilt left/right, about X axis)
    data[2] = atan(gravity -> y / sqrt(gravity -> x*gravity -> x + gravity -> z*gravity -> z));
    return 0;
}

But I don't have mathematical knowledge.  :-[

please help me to do that. many thanks...

  • so are you saying you want the angles to continue increasing after 359.999 degrees - but as 360 degrees and 0 degrees are the same angle, you will have to assume a maximum rate of change so you know that 359->0 is a continued anti-clockwise rotation and not a very rapid clockwise rotation. On that basis, why don't you add in another layer of function which keeps some knowledge of previous readings so e.g. a change from >180 to 0 is reported as >180 to 360, and <180->0 is reported as 0, – DisappointedByUnaccountableMod Mar 13 '17 at 10:34
  • yes. I use jeff codes because that use very good kalman filter and output is very accurate. but I need freely rotational , not 0 to 360. – Saeed Shahriyari Mar 13 '17 at 11:52
  • So why don't you write some code that does that, then. The maths involved is probably just comparison, adding and subtracting. Good luck! – DisappointedByUnaccountableMod Mar 13 '17 at 12:39
  • And there's no point trying to modify the above code - there is no way to unambiguously differentiate between e.g. 0 degrees and 360 degrees, so you will have to use history to add/subtract multiples of 360 to each axis depending on history of recent change of that axis. – DisappointedByUnaccountableMod Mar 14 '17 at 14:12

0 Answers0