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

  • Merged the diydrones/master branch to my Soar_lib branch - all up to date now!

  • Thanks guys, yes I have pushed these changes to my Soar_lib branch. I will also merge in the diydrones/master soon as my branch is a bit behind now.

  • oh yes!.....I very close to finish glider (with pixhawk)

    Cheers 

    Max

  • This is very good progress. Do you plan to check-in this version to GIT ?

  • I still haven't flight tested the EKF code itself yet, but this week I have testing some important helper features which I think will make future testing a lot easier.

    The first is to allow the use of the motor in soaring flight to get up to altitude. The way it works is like this: the plane is tuned up for powered flight with THR_MAX set to 65% in my case (previously it was zero to prevent any use of throttle in non-manual modes). A mission is set up - I have mine at 300m altitude. There are two new parameters in the soaring code that control the throttle - SOAR_ALT_MAX and SOAR_ALT_MIN. When the plane climbs to SOAR_ALT_MAX, the throttle is disabled and the plane will continue the mission on a glide. When it descends to SOAR_ALT_MIN, the throttle is enabled again and the plane will begin to climb back to SOAR_ALT_MAX. I have my SOAR_ALT_MAX set to 160m and SOAR_ALT_MIN to 80m. The soaring code is only able to turn the throttle off when in FBWB or AUTO modes so RTL and GUIDED modes can work as normal.

    This means that an AUTO mission can fly a circuit, climbing back to altitude when necessary and picking up any thermals it encounters while gliding, without any manual intervention. RTL and GUIDED modes can also be used for failsafe and geofencing without worrying about running out of altitude.

    Here's one with three climbs:

    3701805416?profile=original

    The second is a wind feed-forward to improve tracking of thermals. While thermalling in manual or FBWB modes I find I usually need to follow thermals downwind. Up to now the assumption of the soaring controller has been that thermals are basically stationary above the ground. The EKF can still track any downwind drift of a thermal but it will lag the true thermal position and reduce centring performance. Now the wind speed estimate from the AHRS is used to move the estimated position of the thermal downwind.

    3701805557?profile=original

    So this is just to show that I am making some progress.

    The next things to test actually require the sun to come out and make thermals!

    Cheers,

    Sam

  • The ASG is for next year, at best. I might work on this during next winter. Sam's EKF already seems well worthy. I wish I could compile it as well. Could you PM me? Thanks.

  • i compiled on pixhawk. I'ts fine. 

    No, i'm speaking about ASG filter software

  • Hi massimo,

    The code is there, but I haven't been able to build it yet.

    https://github.com/samuelctabor/ardupilot

    samuelctabor/ardupilot
    ArduPlane, ArduCopter, ArduRover source. Contribute to samuelctabor/ardupilot development by creating an account on GitHub.
  • hi everyone. Sam, Fabien. It's just arrive me a Cyclops-E with 2.6mt wingspan. Now I have pixhawk with digital airspeed sensor.  I hope that guys share ASG filter software!

    max

  • What impresses me about the ASG filter is its ability to core the thermal within 1.5 turn. I've ask the university guys if they would share their code, but so far no response from them.

    Lets work with your EKF for now and this winter we might have time to test both. 

This reply was deleted.