Ardusoar cross country X-Plane simulation


Hello all,

I have been doing some work on Peter Braswell's Ardusoar code ( to improve thermal centring.

I finally got around to getting HIL working in XPlane to allow some cross country soaring simulations. I am using the PT60 model which has a terrible glide ratio (about 1:7) so thermal strength has been set quite high (1000 ft/min) although thermal coverage is only 10%. The Ardusoar code is working very well - the extended Kalman filter does a good job of centring thermals and almost never loses them. The throttle is set to zero when soaring but is re-enabled if the altitude drops too low, allowing automated climbs back to a good altitude. The flight mode is AUTO until an updraft is encountered (climbrate exceeds a certain threshold) at which point the mode is switched to LOITER. In LOITER mode, the Kalman filter is updated whenever new measurements (GPS positions and barometric altitude) are available. The update takes 4-5ms and doesn't appear to slow down the main loop below 50Hz. My repository is here if anyone is interested in trying out the code.

Below is a several kilometre flight (this was a 5-hour Xplane flight) with quite a lot of thermal encounters. The code includes logic about whether a thermal at a given strength and height is worth taking. This leads to quite a few brief thermal encounters in which the algorithm begins to search for the thermal but decided not to continue based on the thermals strength (too weak for the altitude the plane is at).

Below is the altitude throughout the flight (after the initial climb to 850m, the motor is off). There are a few long thermal climbs, especially early in the flight up to 3000m (cloudbase).3689576511?profile=original

Below is a close up of a typical climb. After switching to loiter mode (purple)  it takes a couple of circles to centre the thermal. 


The filter's states are saving in the onboard log to allow post-flight analysis. Here the algorithm's estimate of the thermal centre location is the blue track. You can see it moves it quite a bit during the initial centring and very little after that.3689576591?profile=original

The internal model of the updraft strength is a Gaussian distribution. Effectively the Kalman filter tries to adjust the estimated strength size and location to match the measurements.


As you can see the states change quite a lot during the initial centring. After that they are quite stable except for some ripple. This is due to the XPlane thermals not quite matching the Gaussian distribution assumed in the algorithm.


I am hoping to do some real-world flight testing when the weather improves here. Eventually this code is going to be used in a 3m balsa Bird of Time glider I am building, but flight testing will probably be done on something a little more tough and expendable, probably a Parkzone Radian.


Happy flying!


E-mail me when people leave their comments –

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

Join diydrones


  • Hey Mike,

    All the gui does is update the Simulation object on a timer and allows setting params. If you can't get Matlab you can just do a simple script like this:


    simulation = Simulation(ax);

    for i=1:1000

  • Sam,

    I did some more checking and Octave doesn't yet have a gui capability. So I guess it's back to Windows to see if I can get an old student version of MatLab to install and work. SITL is an option but right now I'm writting a C++ simulation to parallel your work. Part of my effort to learn the language so I can dig into ArduPilot and the soaring PR.

  • Hey Mike,

    Yes I am also very pleased it's going into master! It has really re-invigorated my motivation for this project and I'm working on some new features now. Wow yes it seems a long time ago that I used that code, I now do most of my testing in SITL. However I just tried downloading it again from my github and it worked fine. gui_mainfcn is a Matlab built-in so maybe it's an Octave issue?

    >> which gui_mainfcn

  • Sam,

    I've been following the pull request to ArduPilot. Great to see your work going into the system! I was trying to run your Matlab simulator from your GitHub repo using Octave (linux). There is some missing code to get it running. The function, gui_mainfcn, is missing. Can you share the code you are using to test the latest pr?


  • only a very early version of thermopilot has been released so far - version 1.1.

    first i need the logic being correct and then i adapt the ardusoar kalman filter.

  • Hi Robert,

    On step ahead of me :). I am adapting a version of ArduSoar for UAVXArm. I just need to either add some thermals to the inbuilt emulation or interface to FG/XPlane.

    When you say ThermoPilot does that mean you were actually able to get the ThermoPilot code from way back?

  • hi greg,

    i have an untested c++ variant of my sw which includes the thermopilot funcionality for stm...

    i hope to have time next summer ...

    my only problem is the groundstation support ...

  • Excellent REAL results after ThermoPilot way back - what happened to that BTW?

    Has anyone given some thought to extending to exploiting slope or ridge lift?


  • @Sam, FYI, I have ArduPlane 3.5.1 fully functional and reasonably well tuned on a Radian Pro, with PixFalcon brain, digital airspeed sensor, Dragonlink Advanced v3 for long range RC and telemetry, PFV cam and HD cam with DVR on board.  Looking forward to taking ArduSoar for a spin once Tridge gets some sim time under our collective belts.  Thanks for the lead on a glider for X-Plane.


  • Hi Andrew,

    Great new about X-Plane and nice to hear you're getting involved in the soaring stuff! I've successfully used this plane in the past:



This reply was deleted.