MPU6050 - OUTPUT_READABLE_YAWPITCHROLL
Hello, Jeff! Thank you for a great library. Your MPU6050 driver is working fine on my Arduino UNO, but I faced some issues in calculating readable yaw-pitch-roll.
I've noticed two problems:
- Event if the chip was not moved even a tiny bit since the the moment the MPU was initialized, the initial values of yaw-pitch-roll are between
1and3. It seems to me they must all be0right after the initialization if the chip was not moved. - Even if the chip is absolutely fixed on the steady surface the yaw-pitch-roll values continuously change with deltas about
1degree ( e.g. from3.000to3.999). Is it how the device and the driver are supposed to work or I'm doing something wrong?
Any help or answer is greatly appreciated!
Hi @Kolyunya,
In my experience, it takes about 8 seconds of no motion after startup for an uncalibrated sensor to produce steady values with the DMP. Once this initial calibration occurs, the roll, pitch, and yaw values should be very stable, especially the roll and pitch. The yaw value is subject to a very tiny amount of drift since there is no magnetometer present in the device, and no absolute reference point available for the heading (yaw). Roll and pitch are calculated from the gyro movements as well, but fused with gravity data from the accelerometer, and so should be exactly stable once calibration completes--assuming the sensor isn't moving.
- It is common for the pitch/roll values to be non-zero even after calibration, since it means the sensor isn't 100% exactly "level" with respect to gravity. This is hard to measure precisely with a carpenter's level or something because the MPU chip itself is so small, but you should be able to fix the values by slightly changing the X/Y tilt of the device.
- On my device, when it is holding still and running the MPU6050_DMP demo sketch, the y/p/r values are stable to within about +/- 0.02 degrees. You should not be seeing fluctuations of +/- 1.0 degrees.
Thank you very much for a quick answer, Jeff!
- I get it now. I used to think that YPR should always be zero if the sensor was not moved since initialization.
- For some reason it takes about 30 seconds for the sensor to calibrate on my Arduino. Maybe you know, how to fix it? Do I get it right that calibration process starts after initializing DMP, right?
- Yes, after 30 seconds of calibration the values are stable within about +/-0.02 degrees
Just some perhiphery: Mine calibrates in a few seconds... calibrates/gets stable. Since mine is not always starting from level, but I want the display to indicate level at odd angles - I put a button that levels everything.
Basically, here is what I do (example for pitch): Get the pitch from the MPU, var pitchAngleDegreesShort pitchAngleDegreesShort = (ypr[1]-1 * 180/M_PI)-100; Is the "Level" button hit? Yes - set the current pitch to a var, pitchAngleLevel Then, whenever I display the pitchAngleDegrees on the LCD, it is calculated like: pitchAngleDegrees = (pitchAngleDegreesShort - pitchAngleLevel)/100;
Code (don't hate me, I'm not a coder!) is here: https://github.com/mikegreen/accel-o-fly/blob/master/accel_o_fly/accel_o_fly.ino
Don't read into the project that much - it works great in a car but lacks the kalman/etc fun yet.. When I went out and flew with it - any coordinated turn shows a level bank attitude as the MPU thinks we have 1G pulling straight down.. in reality we're turning at 3 degrees per second.
did anyone tried to correct the pitch and roll values as both of them are not going above 90 degrees?? any help?
Hi jeff, Thank you for a great library. Yaw angle is continuously decreasing. This decrease occurs to at every reading and this scale is 0.01 degrees. Roll and pitch angles are very stable but roll angle is -1.22 degrees and pitch angle +1.90 degrees. Yaw angle starting to at 12.95 degrees. I will use for quadcopter project.
1-) I could not find kalman filter for mpu6050 (for yaw, pitch,roll) Could you help in this regard?
2-) I have got a l3g4200 gyro and adxl345 accel and ı want to calculate yaw-pitch-roll this sensors. Could you help in this regard?
I'm using Arduino Mega 2560.
Any help or answer is greatly appreciated!
Here is the video example for MPU-6050 with readable data. https://www.youtube.com/watch?v=D5HY_tjW1lc
the roll and pitch are not completely error free! i wrote a sketch to send the orientation from the dmp over a serial connection to my laptop and compared them with angles calculated using a kalman filter. there is usually a 3 degree error. the most error is while the device is rotating (upto 15degrees) maybe il put up a video later to show the difference.
@k1tk4t I have also noticed that the DMP data get's less accurate as the device is turning. I believe it gets better if you increase the FIFO rate however that comes at the cost of computation time. Can you put up your kalman filter code? Did you use the raw data for that?
I used getMotion6() and getRotation() for getting the data. The Kalman filter was from http://forum.arduino.cc/index.php?action=dlattach;topic=202007.0;attach=64238
Whats the maximum fifo rate? Im using 100hz right now.
The Roll and pitch never seemed to settle at the same values if I picked up the device from a level surface and put it down. There would always be about 2 degrees of difference.With Kalman it seems much better. Did anyone else face this problem?
Maximum rate is 200HZ (0x00 set in line 311 of MPU6050_6Axis_MotionApps20.h) .
When I did my application I ended up using a much lower frequency (20 Hz) because I found that it resulted in less buffer overflow errors and a more repeatable measurement after the data settled. I didn't care too much about the accuracy of the reading as the device was turning so I would give it a few seconds to settle after a turn to get a more repeatable measure.
Yaw is continuously drifting after 8, 12 or even a minute, while outputting data to teapot (processing). Roll and Pitch values are stable though. How to get about fixing the yaw drift?
How can I calculate yaw angle? I am calculating roll and pitch with Kalman filter for my quadrotor. But I don't know to use which quation for that.
Thank you for your libraries Jeff they have been very helpful! :) I am having the same problem with the yaw initially drifting. I have found that it goes stable after approximately 15 seconds.
Hi, I am using MPU6050 with the DMP6 example. The IMU is working fine except the values do not ever reach 90 deg when the IMU is placed vertical around pitch or roll axis. Instead the values just touch 60deg or sometimes 50deg. Timely response is highly appreciated. Regards and thanks in advance.