The mpu gives me perfectly fine values for the yaw, pitch, and roll position of the chip, but when I use
mpu.getRotation(&gx, &gy, &gz) to obtain the current angular velocity of the chip, the values returned are awful. I wrote a program in Processing to graph the data from my Arduino, and this is what it looks like:
I suggest you click on the picture and zoom in a bit because it's difficult to see. The green line represents zero (0), the Pink line represents the angular position of the mpu6050 chip, obtained from
mpu.getYawPitchRoll..., and the Blue line represents the angular velocity on the same rotational axis.
A few extra things to note:
- The scale between the Pink and the Blue lines is slightly off, but that shouldn't matter for this purpose.
- The time-frame for this graph is about 16s.
- Before being graphed, the raw gx value is divided by the gyro's sensitivity scale factor, 131, and then converted from radians to degrees.
In addition to this, it is also put through a complementary filter, so the whole formula looks like this:
rollRate = (0.7*rollRate) + (0.3*(-180 * gx / 131 / M_PI));
As you can see, the measurements for angular velocity (Blue) make almost no sense when graphed next to the angular position (Pink).
My question is this: What can I do to clean-up/filter these angular velocities and get rid of all the errors? I need these values to be accurate enough to be used in something like a drone PID.
Things I have tried:
- Complementary filters of various proportions.
- Adjusting the MPU's built in low-pass filter.
Thanks for any suggestions.