Hi all!

I've been into FPV for a few months now, and one of the things I've wanted to do was visualise practice race courses over the top of the FPV video feed.  That way I can practice courses at a higher altitude, with more variations, in a space (think: park) that in itself may have no natural obstacles.

I've spent some time doing research, and think it can be done using IMU/Baro/GPS + EKF, hopefully yielding an "accurate enough" position.  It doesn't have to be perfect, I'd say as long as the position isn't jumping around by more than 20cm it would be usable.  I've played with a couple of 9/10DOF IMU sensors and have a GPS sitting on my table ready to use....  except I'm getting stuck at the "how do I fuse that with the other sensor values?" part.

I've read Simon Levys excellent EKF tutorial (http://home.wlu.edu/~levys/kalman_tutorial/) and I understand most of it. It doesn't go into enough detail for me on how I'd get GPS into the mix, nor do I understand how I form the Jacobian matrices. It's right at that part that my eyes begin to glaze over. I feel like I need help with that particular piece as it's clearly not my area!


Can someone with more experience perhaps guide me in either what I should read, or code that I could adapt?  My goal at this stage is to develop & understand enough that I am processing the raw sensor values, mixing that with the GPS via EKF and ending up with coords that I can use.  

I've found various examples that run filters over accel / gyro data, but nothing that is mixing both the integrations of those (to get IMU based position), with GPS data that is supplied at a lower Hz. 

Open to any help or suggestions!

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

Join diydrones

Email me when people reply –


  • I've tried this and current gen of mems gyro/accel are not nearly good enough.

    I performed the follwing test:

    1. Attached the sensor to a granite slab so it couldn't move
    2. Measured the sensor bias in all six axii
    3. Integrated the output

    In a minute it showed as multiple meters out of position.  Vibration and actual movement will make this much much worse.

    In the future, hopefully we will have sensor 1000X better and then short term dead reackoning will be viable.

    Side note,  integration should be done with 64bit floats as 32 bit floats only have ~7 decimal digits of range, which isn't enough to both show position as a body moves and maintain enough resolution to integrate effectively.

    • Hi Phillip,

      Yeh, I expect that after a couple of minutes. What I'm really hoping for is that I can get a reasonable fix with GPS, and have the mems provide intermediate output in between GPS fixes.  That way it need only be good enough for 1/5th a second or so  (hence the extended kalman). Of course; this assumes that the GPS is itself "good enough" when filtered. So many things yet to actually test, but have to say I'm having fun learning it (it's been a while since I've done something like this).

      I've been doing more reading, and am "further" towards a good understanding. Still not up to the details of extended yet.  However I can see how to do the fusion, and provide differing weights to the predictions and measurements using variance.

      I'm working my way through: https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python. Currently in ch8.

      Kalman Filter book using Jupyter Notebook. Focuses on building intuition and experience, not formal proofs. Includes Kalman filters,extended Kalman…
      • Oh, and very cool link.

      • If all you want is what I would call "short term dead reckoning", then that is very doable.  ArduPilot does this already.

          I got into this by wanting to write my own drone control software and incorporate long term dead reckoning into it.  Many people said it could not be done.  I tried any way in the name of learning.  They were right, but I won in the end given how much I learned trying.  Some of this is discussed in my blog: http://philstech.blogspot.com/2012/03/quadcopter-project-overview.html

         All my code has been written the arduino platform since it is easy and I enjoy the challenge of trying to make things work with very limited processing power.  I moved on from dead reckoning to create my own quaternion based complimentary filter.  It's not "better" than other options around, but I learned a ton doing it.

        Quadcopter Project Overview
        A blog about technology focusing on multicopters, my quaternion based IMU, and any thing else that catches my interest.
        • It's partly why I'm going down this track. I know the existing ArduCopter code has EKF, but since I don't understand it I'm starting with the basics. I too want to place this onto a small Arduino board. Even if it's just a temporary thing and I move on from here, it'll be nice to get an understanding of the fundamentals so that I can look at various bits of code and apply just what I need (given the limited RAM space/speed of an Arduino).

          Oh, and I have your complementary filter post sitting in a browser someplace, ready for reading. When I get the time :)

This reply was deleted.


Laurie J. Troy liked Jasper Kueppers's profile
Apr 1
Timothy Miller liked Joseph Udofia's profile
Mar 18
Joseph Udofia liked Joseph Udofia's profile
Mar 3