Allan Variance (plots and code)

Based on the sample data provided by Loris I have written some code to produce an Allan Variance plot of the data. The program source code is ISO C++98, and should compile with any standards-compliant compiler. G++ 4.4 tested, I expect MSVC 2k8 or higher to also handle the file just fine.

This particular program is somewhat specific to the data provided by Loris. It expects 16x oversampled sums, in integer ADC counts. The code performs the floating-point division back to native counts itself.  Just compile and link the program in one command:
$ gcc -o allan_variance allan_variance.cpp

To run the program, provide it with a data file and the sampling interval. The data file must be provided as a list of whitespace-separated ADC samples, with six channels per entry. The first three channels are treated as x, y, and z axis gyros, and the remaining three channels are ignored.

Prior to actually using the data file, I massaged it somewhat. The original file has some weird line endings, something like \r\r\n. So I piped it through dos2unix and removed the blank lines with sed.



Over the entire sample period, the noise is dominated by white noise in the sensor, not by bias drift. I expect that the bias drift won't show up until the data stream is much longer, on the order of half an hour or so.  Gnumeric was used to produce the plot.

realtime_samples_variance.gnumeric

allan_variance.cpp

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • This is an interesting discussion. Although it's kind of late, but I'd like to seek your help to tune my EKF covariance matrices in order to get a better estimation of the attitude.

    How do you suggest to start?

    What I currently do is that I use matlab var() function in order to find the variance for each axis of the gyro, accelerometer and magnetometer?

    Is that ok, or I need to use more advanced things.

    I also would apreciate it if some one can help me with a matlab code for a working EKF attitude estimator.

    I already have one, but I need help to validate the code.  Thanks a lot.

  • hello guys, other than measuring the goodness of gyro, can you tell me what allan variance is used for? i would very much love to use allan variance to improve the accuracy of these sensors/remove errors from gyro drifts.

    could you please explain if the length of samples affect the result of allan variance? from what i read before the larger your cluster size, the less is the error %.

    in the typical graphs i've seen in papers, they log data for days. what should the typical length of data be?

    also, is allan variance data consistent with time? for example would it still be the same 2 mths after u run the last test?
    thanks!
  • I uploaded sample datas : http://code.google.com/p/easy-imu-pilot/source/browse/trunk#trunk/T... The format is csv.

    The bigger one is 200 000 samples at 107Hz so around 30 minutes. I also uploaded 50 000 samples at 160Hz (using a TX buffer) so around 5.5 minutes of data. I didn't change the gyros offset so the long term stability is quit good because the average is less than 0.5°/s.

    The variance is 0.10 - 0.11 ADC steps (for both gyros and acceleros). It means a variance of 0.11°/secs for gyros and 0.001 m/s² for acceleros.
  • Developer
    Jonathan,

    I assume your data was gathered with the IMU sitting on "the bench". I wonder what differences would be seen during "in flight" conditions. Vibration and temperature changes may change the characteristics such that you do see bias drift.

    I don't know that this is the case, but it is worth checking out. There is no sense optimizing code for performance under ideal conditions if the assumptions don't hold in actual use.

    Best Regards,
    Doug
  • Hi,

    You made a great job! Do you plot the whole file? Because there is around 6000 samples so at 150Hz it should last 40s.

    Could you try with the attached data file? It is in presence of noise.

    Could you also try with right shifting (instead of flotting point division). Because what I noticed is the more you right shift, the lower the variance is.

    gyros_var.jpg


    Loris

    real time 16 samples 0 shift with motor2.txt

This reply was deleted.

Activity