MAV-blog

Stuff related to MAV's (and UAV's) from a hobbyist's point of view. Info

Testing Kalman filters

A lot of people think they need great electronics skills, a lot of time, and embedded programming skills to experiment with Kalman filtering of IMU-data. Think again! The key to all your success stories is simulation!

One of the easiest tools that can help you with those simulations, is a great flight sim called Flight gear. It uses advanced aerodynamics simulation libraries, among which some were created by the NASA. Good enough for our purposes! On top of that, you can easily configure Flightgear to log all the data you need. I updated my config file to log the following variables:

  • Roll
  • Pitch
  • Acceleration along the 3 axis
  • Gyro reading along the 3 axis
  • Heading
  • Airspeed
  • ...

All the available fields can be found in FlightGear\docs\README.properties
I added the following lines to the configuration xml:

<logging>
  <log n="0">
   <enabled>true</enabled>
   <interval-ms>100</interval-ms>
   <filename>fg_log.csv</filename>
   <delimiter>,</delimiter>
   <entry n="0">
    <enabled>true</enabled>
    <title>AccX</title>
    <property>/accelerations/pilot/x-accel-fps_sec</property>
   </entry>
   <entry n="1">
    <enabled>true</enabled>
    <title>AccY</title>
    <property>/accelerations/pilot/y-accel-fps_sec</property>
   </entry>
   <entry n="2">
    <enabled>true</enabled>
    <title>AccZ</title>
    <property>/accelerations/pilot/z-accel-fps_sec</property>
   </entry>
   <entry n="3">
    <enabled>true</enabled>
    <title>DRoll</title>
    <property>/orientation/roll-rate-degps</property>
   </entry>
   <entry n="4">
    <enabled>true</enabled>
    <title>DPitch</title>
    <property>/orientation/pitch-rate-degps</property>
   </entry>
   <entry n="5">
    <enabled>true</enabled>
    <title>Roll</title>
    <property>/orientation/roll-deg</property>
   </entry>
   <entry n="6">
    <enabled>true</enabled>
    <title>Pitch</title>
    <property>/orientation/pitch-deg</property>
   </entry>
      <entry n="7">
    <enabled>true</enabled>
    <title>Heading</title>
    <property>/orientation/heading-deg</property>
   </entry>
   <entry n="8">
    <enabled>true</enabled>
    <title>airspeed</title>
    <property>/velocities/airspeed-kt</property>
   </entry>
  </log>
 </logging>

Then I created a small VB tool (Yeah, kalman filters in VB ;-) ) to filter the data. This is the result:

One thing you can see, is that if I calculate the centripetal acceleration, and substract it from my y and z acceleration, the resulting roll angle has a standard deviation of only 2 degrees. Not bad!

Files for you download pleasures:

20 November 2007, 21:55 | Link |
  1. It is possible to filter a orientation on 3 axes with a kalman filter ?



    Damien CONSTANS, 22 November 2007, 11:08 | #



  2. Sure, the number of axis doesn’t matter. A kalman filter is just a mathematical tool. The model you’ll be using in it does matter!



    Tom, 6 December 2007, 10:33 | #



  3. I was looking at void ars_predict(). I expect something like “P_11*dt*dt” in your P_00 prediction.



    Guy Guns, 7 December 2007, 16:31 | #



  4. Aaah, the good old engineering trick:
    dt is, let’s say, maximum about 0.1
    This means dt*dt is maximum 0.01
    Compared to the other factors in this formula (with just dt), it is “insignificantly” small and is dropped…



    Tom, 7 December 2007, 21:51 | #



  5. Hi, may I know how you calculate and subtract the centripetal acceleration from your filter?



    WaiWeng, 20 January 2008, 04:48 | #



  6. @WaiWeng,
    Currently I’m testing 3 approaches here, two where the centripetal force is calculated, and one where it is estimated with a kalman filter. In flightgear they all work good enough, but in a real MAV, things are more complicated :-)
    I only tested one option yet in a real MAV, and it worked, but only in light wind conditions… So more testing is required.



    Tom, 20 January 2008, 16:43 | #



  7. can i know make simple kalman prediction code in vb6



    ferdi, 17 April 2008, 10:30 | #



  8. I have been trying to do Kalman using Bascom and Avr chips but no sucess. Do you have any that help me to “find the light” on this…? I mean some guide but using the Bascom language..?



    Humberto, 6 June 2008, 16:57 | #



  9. Hello Tom. I’m read your code, unfortunatly I don’t have your original programming language so I can’t run it as is. I translated everithing to Delphi (my favorite) and now its running, but due I can’t compare the results I’m asking you, in your code, from wich ones variables did you make the chart? If I can match your chart with the .csv data then I will now I sucessfull translated your code to Delphi.

    Thanks!!!!



    Humberto, 13 June 2008, 20:38 | #



  10. Hi,

    you used an extended kalman filter (linearized). Can you give me the state space model that you’ve used? Or a reference that I can read?
    Thanks in advance,
    Sergio



    Sergio, 23 June 2008, 21:49 | #



  11. Sergio, it is explained in http://tom.pycke.be/mav/71/kalman-filtering-of-imu-data



    Tom, 24 June 2008, 18:21 | #



  12. I installed flight gear, but how do you open the readme files. Tried notepad and that didn’t work.



    Justin, 17 September 2008, 22:20 | #



  13. Thanks!!!!



    sensors for mnav, 7 October 2008, 20:20 | #



  14. Could someone explain to me that how did tom manage to calculate centripetal acceleration when neither radius of curve nor mass of plane is known… also please tell me precisely that how the accelerometer readings are compensated using the calculated centripetal acceleration… Any help would be appreciated!



    Kalman, 22 March 2009, 12:08 | #



  15. Which file did you modify for logging the data flight? Was it the preference.xml? Thanks



    Frank, 14 April 2009, 01:56 | #



  16. Hi, i am trying to implement the kalman filter in Visual Basic 6.0 and i found the code that Tom posted here in VB.Net. My question is what of the file\files contain the code that i should reprogram to VB6? I was looking around and i found the Form1.vb and Form1.Designer.vb but the last one seems to be generated by visual basic… Anyone can help me? Thank you very much.



    alejos, 12 July 2009, 10:16 | #



  17. Hey. Nothing is as simple as we hope it will be.
    I am from Estonia and too bad know English, give true I wrote the following sentence: “Gel nails designs, alert animal months support picoseconds to operate cokin complications.”

    With respect :-D, Pink gel for acrylic nails.



    Pink gel for acrylic nails, 28 August 2009, 15:19 | #



  18. hey i’m using picbasic pro…still new in this
    does anyone hav experience writing kalman filter using picbasic pro?



    Dan, 24 November 2009, 17:15 | #



  19. hey is there any reason u read 16bit out of your ADC registers in your code instead of 10bits since the resolution is only 10 bits.



    pizza, 26 January 2010, 03:46 | #



Name
E-Mail
http://
Message
  Textile Help

|