Hey guys.  This may be slightly off-topic but I thought I'd cast a wide net and see what I could come up with.

I've been experimenting with autonomous soaring based on modified code running in on ArduPilot hardware.  I've had some limited success with simple algorithms that look at the current rate of climb indications and circle / cruise accordingly.  Here's a link to the fork:


I've run across a number of academic papers describing in graphic detail some of the mathematics of autonomous soaring but they all go way over my head.  Most talk about Kalman filters and a bunch of other smoothing logic.  Anyway, my question has to to with taking this to the next level.  Not sure if you all are aware of any resources or projects, code or libraries that I might be able to leverage.  Like I said, a bit of a long shot but thought I'd try.


Views: 4135

Reply to This

Replies to This Discussion

I'm more on the copter side rather than the plane side but I do hear people talking about autonomous soaring now and then on the forums so there is some interest out there.

The ArduPlane code is pretty mature now (i.e. very few bugs) and still has plenty of free RAM and CPU cycles so I'm pretty sure it's possible to extend it for what you're talking about...but personally i'm not in a position to help with that..

I wrote some code for a paraglider pilot vario (uses an IIR filter + linear regression).  It is reasonably well tested (>3K regular users).  If you need a way to get a good vario reading from the barometer in the APM you might try stealing this algorithm.  See getVerticalSpeed in this class:


The code is pretty straightforward Java and all in that project.  You just need the IIR and and regression code.

The standard rule for paraglider pilots is: when the vario starts making the happy noise, fly for up to four seconds (you'd want to make that # adjustable) or until lift starts going down, then start a right (or left) turn.  Alter the diameter of the turn to optimize rate of climb (to core the thermal).

And I should add - I'd love to use/help with this project.  I _really_ want to work on thermalling a APM or PX4.  Alas, I'm busy with two other UAV projects first (finishing up my android GCS then I want to have a plane follow a paraglider pilot)

@kevin - well certainly if time permits, I'd love to have other eyeballs on the code. 

Thanks for the code too.  I was hoping to solicit incremental improvements as I'm certain that other folks have already tweaked the code to do some of the things I'm after, your snippet is a case in point.  I had to modify and add a few functions to get rate of climb information reliably.  It looks like there's already a ROC code in there, but it depends on consistent reads of the barometer and altimeter to seed the smoothing filter.  I will certainly take a look at your code and compare.  It very well may be optimized more for what I'm doing.

Your synopsis of the entering a thermal based on the vario chirps for paragliders is exactly the same as for gliders.  I may be over-reaching but my ultimate goal is to make the APM smart about thermal centering, if that's even possible.  To extend your synopsis: once in a thermal, if the chirps fall off, you're flying out of the thermal and you have to increase bank.  If the chirps go up, you're passing through the core so decrease your bank.  Wash, rinse, repeat until your ROC decays below the average day's thermal strength.  Then proceed on course / to the next thermal / whatever. 

I think that it is possible to describe this mathematically, but I'll definitely need to smooth and trend the decision data before deciding on a control input.  That and the calculations need to be done within the threshold of the control loop, 50Hz as I recall?  I don't think that's a problem, but not sure ...



Great research, if it comes to fruition then it could be combined with flight for powered models for long distance autonomous flights

Some of my planes under manual control can stay in the air indefinately but with the current software it cannot do that automatically and is therefore restircted to battery capacity/efficiency

Jean Louis already has this working look for his posts.

Hi Peter,

Nice to see so much interest in autonomous soaring! I have been doing a lot of research into this in the last few weeks (finals are coming up so I need something to prevent study!). I have been experimenting with implementing Kalman filters etc. for thermal seeking and it works pretty well in my crude Matlab simulation.

Basically the aircraft is provided with horizontal position and velocity information (mimicking GPS etc.) along with noisy vertical velocity e.g. from GPS or barometer. The Extended Kalman filter maintains a model of where it thinks the thermal is relative to the aircraft along with estimated of strength and size.

The aircraft is in one of four states - one for flying a search pattern (a spiral), one for estimating thermal position once updraft is located (a set circular manoeuvre - this allows the filter to estimate the thermal position more accurately), a thermalling mode where the aircraft orbits the thermal centre, and a cruise mode where the aircraft tracks to the next waypoint. 

The aircraft switches state depending on the local updraft (low-pass filtered), estimated thermal size and strength, current altitude etc. The simulation nearly always centres thermals once found (note the thermals are based on the Gaussian distribution of updraft found in the literature, and a global sink is added to enforce mass conservation).

I want to test this algorithm with FlightGear but unfortunately my laptop just won't cut the mustard. 

Anyway take a look at the video and if you'd like to have a go collaborating at implementing some of the ideas on Arduplane let me know and I can send code etc. I don't have much experience with C and don't have an APM (yet) but I'm interested as to how feasible it would be to implement a Kalman filter: it involves quite a few matrix multiplication and inverting a 4x4 matrix. I have a few other ideas as well, such as optimising aircraft speed (speed for minimal sinkrate when thermalling, speed for max L/D when cruising, corrected for local air sink) and using aircraft roll rate as well as vertical speed to detect thermals.


I have been flying a motor glider and power off in loiter I can go up pretty well until that thermal has moved on downwind. So well in fact that its hard to come down. The sunburn that I acquire points to the pain that the airframe is experiencing as well. UV and internal heat will be a big issue.

Logging the positions of thermals entered and returning to those spots might be a very simple and not all that smart method.

If soaring worked well I could use a smaller airframe for a daylight job.

Hi Sam

Brilliant!  Your work really looks promising!  I would love to collaborate if you're up for it.  Your implementation of a Kalman filter is on the right track as far as my limited research has uncovered.  It seems the best technique to smooth the typically chaotic data within the context of a thermal. 

I'm decent at C/C++ (though it's been a while, I do mostly Ruby now).  I've been able to make some modification to the ArduPilot codebase with some success.  I'd be totally up for collaborating and sharing some ideas.  I've also gotten pretty decent at setting up the HIL (Hardware in Loop) simulations of the ArduPilot within XPlane.  I also have some donor R/C models that could be used for RL experiments.

If you'd like to reach me via email, I'm at peter.braswell@gmail.com.  Let's get started!!! :)


Try circle mode instead if you're feeling adventurous.  Loiter tries to keep you centered over a point on the ground, circle just sets a bank angle, thus circle will allow you to drift with the wind and the thermal...



     "Kalman Filter" can mean many things I've heard but you may hit performance limits.  The ArduPlane code only uses up about 50% of the APM's CPU I think...I've never specifically measured it but it's an estimate based upon what i know about ArduCopter which is using 100% of the CPU..and know that ArduPlane is a lot less intensive.

      We've implemented an AP_InertialNav lib for arducopter but just for estimating the copter's position based on gps, baro and accel data...in case that's of any use.  best of luck.

Reply to Discussion



Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service