Ardusoar cross country X-Plane simulation

3689576559?profile=original

Hello all,

I have been doing some work on Peter Braswell's Ardusoar code (http://diydrones.com/forum/topics/autonomous-soaring?xg_source=activity) 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. https://github.com/samuelctabor/Arduplane

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. 

3689576618?profile=original

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.

3689576534?profile=original

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.

3689576642?profile=original

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.

3689576664?profile=original

Happy flying!

Sam

E-mail me when people leave their comments –

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

Join diydrones

Comments

  • 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:

    figure;

    ax=gca;
    simulation = Simulation(ax);

    for i=1:1000
    simulation.Update(0.01);
    drawnow;
    end

  • 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
    /usr/local/MATLAB/R2016b/toolbox/matlab/guide/gui_mainfcn.m

  • 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?

    Mike

  • 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?

    Greg

  • @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.

    Kelly

  • 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:

    https://drive.google.com/open?id=0B4xnWmfKh4FrRHcyZloyWkd1VWs

    Cheers,

    Sam

This reply was deleted.