Yaw Drift

Asked by Michael

Fabio I've read the other threads about yaw drift and really need an answer. I created a sketch that simply calls getYawPitchRoll() and outputs each through Serial.print. When the sensor is completely motionless sitting on the table, Pitch stabilizes at about 8.5 degrees, Roll stabilizes around .2 degrees, but Yaw steadily increases without stopping. I created another sketch that calls getRawValues() and outputs the average raw value for each gyroscope axis after 100000 samples and the results were:

Note: this assumes values[3] is x, values[4] is y, and values[5] is z
x: 30
y: 6
z: 0

I looked into your code and saw that you calibrate the sensors before processing begins but this problem still happens. Any way to fix this? We're really pressed for time.

Thanks,
Mike

Question information

Language:
English Edit question
Status:
Answered
For:
FreeIMU Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Fabio Varesano (fabio-varesano) said :
#1

Yaw drift is given by a magnetometer which has some high bias which would require calibration. At the moment there are no public code for calibrating the magnetometer, a part from some mathlab examples. See http://forum.sparkfun.com/viewtopic.php?f=14&t=18510 for more details.

However, if you see a continuously rotating effect you may have a bad software orientation of the sensor axis. Which board are you using?

Also, note that the first instants after an Arduino reset/software upload are used to calibrate the gyro, so if you don't keep the board steady it will calibrate incorrectly possibly giving you this kind of bad performance.

Revision history for this message
Michael (mlorenzo) said :
#2

Fabio,

We are using the 6DOM board without the magnetometer (ITG3200/ADXL345 combo board from SparkFun).

The board was completely motionless during the entire test period, including loading code.

Revision history for this message
Fabio Varesano (fabio-varesano) said :
#3

I'd like to see some of the output from FreeIMU_raw

Revision history for this message
Ernie Wilson (ernieumass) said :
#4

Hello:

I Mike Lorenzo's senior design project partner. I believe that I may have found the reason for our yaw drift. We have the ADXL345 accelerometer AND the ITG3200 gyroscope, but in the following code, it looks as if when it looks for the ADXL345 and finds it, it never executes the code to indicate that it has an ITG3200:

FreeIMU::FreeIMU() {
  #if HAS_ADXL345()
    acc = ADXL345();
  #elif HAS_ITG3200()
    acc = BMA180();
    gyro = ITG3200();
  #endif
  #if HAS_HMC5883L()
    magn = HMC58X3();
  #endif

Is this true? Mike told me to ask you before I stated "f-ing" with the code. Thanks for your time!!!

Revision history for this message
Fabio Varesano (fabio-varesano) said :
#5

Uh.. I think you are right! Can you provide a fix?

Revision history for this message
Ryan Kelly (ryanpkelly11) said :
#6

Fabio,

I am also a partner of Mike's. We tried to fix the code in the FreeIMU library that Ernie previously queried about, however this did not change the drift problem. As of now, when the device is stationary, there seems to be no drift in the quaternion values, which are what I am using to calculate the Euler Angles. However, when the device is moved, the drift begins.

As you requested, here is some of the output of the Raw Values from the 6DOF combo board. The format is (X_acc, Y_acc, Z_acc, X_gyro, Y_gyro, Z_gyro) which is consistent with your array format.

Here is the raw data:
2, 1, 234, 32, 10, 2
2, 2, 234, 33, 10, 1
2, 3, 234, 35, 12, 0
2, 0, 234, 31, 13, 6
2, 0, 234, 33, 11, 4
2, 0, 236, 27, 9, 2
2, 1, 236, 33, 6, -2
2, 1, 237, 29, 4, -3
2, 1, 235, 33, 8, 6
2, 1, 233, 30, 6, 4
4, 2, 237, 33, 8, -4
4, 0, 236, 31, 15, -3
2, 1, 234, 32, 8, 3
2, 1, 236, 30, 8, 4
5, 2, 236, 30, 10, 4
2, 2, 236, 33, 9, -1
4, 1, 237, 30, 9, -4
3, 0, 235, 31, 7, 0
5, 1, 237, 31, 10, 3
2, 0, 235, 30, 5, 2
3, 1, 236, 33, 11, -4
2, 1, 237, 32, 8, 0

This is just a small portion of it, but seconds after the program began running to allow it to stabilize a bit. Again, thank you for your time and all your help.

-Ryan

Revision history for this message
Fabio Varesano (fabio-varesano) said :
#7

Ok, so.. the correct code in the FreeIMU constructor should be like:

FreeIMU::FreeIMU() {
  #if HAS_ADXL345()
    acc = ADXL345();
  #elif HAS_BMA180()
    acc = BMA180();
  #endif

  #if HAS_HMC5883L()
    magn = HMC58X3();
  #endif

  #if HAS_ITG3200()
    gyro = ITG3200();
  #elif HAS_MPU6050()
    accgyro = MPU6050();
  #endif

  #if HAS_MS5611()
    baro = MS561101BA();
  #endif

  // initialize quaternion
  q0 = 1.0f;
  q1 = 0.0f;
  q2 = 0.0f;
  q3 = 0.0f;
  exInt = 0.0;
  eyInt = 0.0;
  ezInt = 0.0;
  twoKp = twoKpDef;
  twoKi = twoKiDef;
  integralFBx = 0.0f, integralFBy = 0.0f, integralFBz = 0.0f;
  lastUpdate = 0;
  now = 0;
}

Could you make a little video of this drifting problem? This would really help understanding what's happening here.

Revision history for this message
Ernie Wilson (ernieumass) said :
#8

Hi Fabio:

OK, I am making a video of this. Where should I send it?

-Ernie

Revision history for this message
Fabio Varesano (fabio-varesano) said :
#9

Youtube?

Revision history for this message
Ryan Kelly (ryanpkelly11) said :
#10

Fabio,

Ernie is working on posting a video. In the mean time, I discovered what appears to be a problem and I was wondering if you have any insight on the matter.

When the raw values are initially read and the gyroscope has not moved at all, they seem to stabilize at (including offsets):

x = 150
y = 28
z = 94

However, after I move the gyroscope and then set it down to rest again, the values seem to vary between some central value that is far from the initial rest values. Here is a stream of some raw data after the gyroscope has been moved and then set down to rest again:

370, 100, 157

378, 59, 101

332, 72, 78

382, 95, 115

362, 57, 150

377, 77, 113

342, 82, 79

371, 98, 88

358, 125, 114

332, 99, 148

398, 83, 104

371, 74, 71

357, 86, 97

363, 92, 148

355, 70, 105

359, 103, 68

318, 90, 128

379, 109, 142

Any insight to why this may be happening? Could it be a problem with the gyroscope itself? And could this be a possible source of our drift in our angle calculations?

Thanks again,
Ryan

Revision history for this message
Ernie Wilson (ernieumass) said :
#11

Hi Fabio:

The yaw drift video is available at

http://youtu.be/bSXu3a0Apew

It starts out a little shaky, but steadies out after a short period so that you can see what is going on.

-Ernie

Revision history for this message
Delphir (r-nbuntu-5) said :
#12

Looks like this is an old thread, but I'm having exactly the same problem with yaw drift of my MPU6050 & HCM5883 with the latest FreeIMU code. Same like described & shooted in video... How this can be solved?

Thanks for your reply!

Can you help with this problem?

Provide an answer of your own, or ask Michael for more information if necessary.

To post a message you must log in.