Ardusoar cross country X-Plane simulation

Hello all,

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

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.

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!

Sam

Views: 861

Tags: Xplane, ardusoar, crosscountry


Moderator
Comment by Gary Mortimer on February 23, 2014 at 7:10am

Looks wonderful well done!

Comment by Hein du Plessis on February 23, 2014 at 8:14am

Amazing work, what about wind and turbulence? Super keen to see it in action in real life tests.

Comment by Antonie Kruger on February 23, 2014 at 8:54am

Hi Sam, that looks great. The wing looks like it has a vulture wing design - very cool. First time I see this. There are many different colours in the flight path. What do these represent. I see the thermal climb is a purple. The wing still blows me away. Would you care to share the design. Are you using a APM2 flight controller?

Thanks for sharing - this is great work.


Moderator
Comment by Morli on February 23, 2014 at 9:43am

Inspirational project. Will follow this with interest. Have AS21 to play with this code once it is ready. Good luck


Moderator
Comment by Gary Mortimer on February 23, 2014 at 11:06am

Its a Bird of Time, classic glider

Comment by Sam Tabor on February 23, 2014 at 11:15am

Thanks guys.

About wind and turbulence, currently these factors are untested but I do intend to investigate their effects. The Kalman filter is designed to cope with noisy data (and the data is already noisy due to aircraft dynamics etc.) so turbulence shouldn't be too much of a problem, although it will probably result in longer times required to centre the thermal. For wind, the estimated thermal centre is moved downwind using the wind estimate that is already in the code. The reason I have not tested this feature yet is that the wind estimate is not available in the HIL simulation (there is another reason - my control strategy is to fly a constant airspeed, but airspeed is not provided to the APM in the HIL simulation. Therefore I assume airspeed=groundspeed when in HIL, which is only true if there is no wind. The presence of wind will degrade the filter's performance. These issues are specific to the HIL simulation and will not be a problem in real flight testing).

The wing is not my design, it is an old (1970's I think) design that is available as a kit or an ARF http://www.dynaflite.com/airplanes/gpma0570.html . I have been building it on and off (mostly off) for the best part of a year now.

The colours are all either LOITER or AUTO mode, Google Earth just cycles though its colours. The long straight parts of the flight are AUTO mode, and the tight circling parts are LOITER mode in which the code searched for the thermal centre. 

Yes it's an APM 2 running modified Arduplane 2.68 code. I am also working on incorporating the code into the latest Arduplane version.

Cheers

Sam

Comment by Antonie Kruger on February 23, 2014 at 11:44am

Thanks Sam - I have my popcorn ready for updates - good work, again.


Developer
Comment by Arthur Benemann on February 23, 2014 at 12:27pm

@Sam Tabor

Incredible work. Bellow are three points that I want to comment:

I'm getting familiar with Kalman filter, so if you could share your system and measurament model matrix I would love to study them.

Also, when you get it to a stable algorithm (maybe even included in the main source) I can help by adding some indicators on the GCS (I'm the main developer of DroidPlanner).

Wouldn't your setup be easier if you where running the SILT (Software in the loop) simulation? I'm not entirely sure (best to check with Andrew Tridgell), but I think it's able to run above real-time speed (reducing your simulation time).

Comment by robert bouwens on February 23, 2014 at 1:29pm

both thumbs up!

Comment by Sam Tabor on February 24, 2014 at 11:09am

Hi Arthur,

Good questions.

The thermal model is the same as the one by Michael Hazard in this paper http://enu.kz/repository/2010/AIAA-2010-179.pdf . It is quite interesting and explains the model well. He uses an unscented Kalman filter, whereas I use an extended Kalman filter. Therefore in my model the Jacobians are calculated by linearising about the current state estimate. The equations are as follows:

This is quite a simple Kalman filter because a) there are no process dynamics so df/dX is just the identity matrix and can be left out, and b) there is only one measurement, so the matrix inversion when calculating the Kalman gain is just a simple division.

Some GCS indicators would eventually be useful, currently Mission Planner displays the heading and distance to the current waypoint which is equivalent to the current thermal position estimate which has been helpful.

As for SITL, I did consider it but I don't think thermal activity or turbulence are currently modelled - I'm sure it's possible to add them but using XPlane has been a good confidence booster in confirming my assumptions about the thermals shape and distributions are accurate, or at least agree with those of the XPlane developers - if I had added them into SITL myself I would risk simply confirming my own assumptions. However I do have a simple Matlab simulation which I used for experimenting and debugging the Kalman filter code.

Cheers

Sam

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2014   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service