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

  • 100KM

    Hello Sam, it's almost flying season here.  How did last summer go with your Ardusoar code?  Were you able to get it compiled for Pixhawk?

  • Thanks Sam, i've take a look at matlab - crazy stuff ;) is my test glide calculation wrong? Last saturday I did some test with the new values and tried the autotakeoff feature

    min_soar at 50m
    max_soar at 150m
    waypoints at 100m

    I suppose the apm tries to hit the wp at 100m and tries to surpressing the soarcode, I have to take a look in the log.

    My test glider is ATM out of order in case of hard treelanding :D have to fix motorshaft and some rudder horns
  • Nice one Thomas, that's useful. I do most of my calculation in Matlab but Excel is definitely more widespread and accessible. I have a spreadsheet at work for estimating the drag polar from test glides that I can add later in the week.

    Cheers,

    Sam

  • Hi Sam, thanks for update I tried to put it in spreadsheet maybe you can doublecheck
    https://docs.google.com/spreadsheets/d/1lclVfHxAuqHG-ZeYvTBmgAYvvnk...
    ardusoar calc
    Tabelle1 inputfields: ouptufields measurements Mass:,4,kg Wing Area:,0.44,m² Wing Span:,3.43,m Density,so,g/cm³,(balsa=0,2 ; paper = 0,8; acrylic g…
  • Hi Thomas,

    Sounds like a nice day out! Windy and rainy here. Just to update your numbers after my mistake, your parameters would be:

    Polar_K 16*0,850/0,24 = 56,7(sealevel)

    Polar_CD0 = 0,041/(default) -> 0,045

    PolarB = 0,033(default) 1,6*1,6/ 0,24 = 10,67 -> 0,377? / 10,67 > 0,035

    The 0.377 (was 0.48 before I correctly my error) comes from my calculated B parameter. The B value is inversely proportional to aspect ratio (actually B = 1/(pi*AR*e), where e is the span efficiency). So to go from one glider to another a fair approximation is to factor B according to the aspect ratios. Your aspect ratio is a little lower, so your B values comes out a little higher. 

    I estimated B for the Radian by choosing a reasonable value of 0.85 for e value which gives a decent fit to the flight test data.

    Cheers,Sam

  • I just realised I got the numbers for Cd0 and B the wrong way round in my previous post! I'll repost it here and delete the old one to avoid confusion.

    Hi guys,

    Sorry for not replying earlier, I have been fighting the good fight with git and make for most of the evening. The good news it that the code is merged into Arduplane 3.2.2 and the github is updated (note I mistyped the commit message as 3.1.1). There is a new APM binary on the google drive (Ardusoar_270415_APM2.hex). 

    The bad news is that I can't get either the vanilla or the soaring versions of Arduplane 3.2.2 to compile for pixhawk! I think this has something to do with the versions of the other PX4 and NuttX related repositories. Looks like there are some other people having similar issues so most likely one of the other repositories was mis-tagged, hopefully this will be fixed. If anyone can get it to compile let me know how!

    Ok some explanation on the drag polar. The APM can work out how quickly the plane is sinking or rising from the barometer. But in still air the plane would sink when gliding, at a rate depending on the plane's shape, weight, airspeed etc. So the drag polar parameters allow the code to work out how much of the measured vertical speed is due to normal gliding, and how much is due to thermal activity. That's why the weight, wing area etc. are needed to work them out.

    My Radian has the following measurements: 

    mass = 0.877 kg

    wing area = 0.35 square metres.

    wing span = 2 metres

    And my parameters are:

    • POLAR_K        = 40.1
    • POLAR_CD0   = 0.042
    • POLAR_B        = 0.033

    Here's how to estimate your parameters without doing test glides.

    • POLAR_K. Work this out as 2*mass*g / (rho*wing area). At sea level this is the same as 16.0*mass/area. (mass in kg, area in square metres). So for my Radian it is 16*0.877 / 0.35 = 40.1.
    • POLAR_CD0. Mine is based on test glides, but it depends mostly on how streamlined the glider is. Use the same as mine, Cd0=0.042. If you have a lot of antennas etc. exposed to the airflow that you could increase it. Similarly if your glider is very clean it could be a little lower.
    • POLAR_B. Mine is based on theory and test glides. Work out yours as follows. Get your gliders aspect ratio (AR=wingspan^2/wing area). For the Radian this is AR = 2^2 / 0.35 = 11.43. Then your B = 0.033*11.43 / AR, or B = 0.377 / AR. This assumes a similar span efficiency to the Radian.

    Generally CD0 and B should be similar to mine, but K will change a lot depending on the wing loading. For example I can increase mine by 45% to 58.4 by putting adding heavy steel spar as ballast on windy days!

    If you have test glide data or you know the sink rate at a given airspeed, let me know and I am happy to work out some better values (or if you have Matlab I can share some useful scripts).

    For mounting the pitot tube, on my Radian I have it under the left wing (you can see it in the photo on page 3). On my Bird of Time (still building it . . . ) I am mounting it inside the wing centre panel. I am going to build a longer pitot tube so that everything is accessible from the spoiler bay. That's the problem, I keep adding extra stuff to it!

    Hope that was helpful.

    Cheers,

    Sam

  • 3701990353?profile=originalHey Folks ! First test completed - too windy but it works ! Smoking cigarretes, drinking beer and flying, my dog also enjoys it. Code performs very well nice to see al the stuff working. It tries to get thermal (but there was no one exept windforced ones) now I just can feel how would work in good conditions. I have some issues with my battery monitor so have to took a walk after medium nice landing but only the pitot tube is a little messy at the intake.

    Parameters:

    "foami"

    mass = 0.85 kg

    wing area = 0.24 square metres.

    wing span = 1,6 metres

    Polar_K 16*0,850/0,24 = 56,7(sealevel)

    Polar_CD0 = 0,033/(default) -> 0,037

    PolarB = 0,042(default) 1,6*1,6/ 0,24 = 10,67 -> 0,48? / 10,67 > 0,045

    Hey Sam why 0,48 ? fixed value ?

    time in air: approx 40 min

    Keep it on, cheers !

  • thanks for the explanation!

    this IS very helpfull.

    one more thing to remember.

  • Good morning, have to get up very early topsy, very nice work and awsome explaination @sam don't have to sorry ;) I don't even get the last version tested. Spend some time with XFLR 5 yesterday.

    @trung my foami is front trust powerd engine is mounted above CG so pitot tube taped to nose. If nosepowerd you have to mount it out of the airflow from the prop for me with the natschalnik the flap servo area is a good choice
  • 100KM

    @ Robert,

    Sorry, I am hesitant to share my very non-expert "understanding" of drag and glide polars.  I don't want to give bad information.  I was just wondering how critical the polar parameters are in Sam's code.

    @ Sam,

    Will the defaults work at all for a glider other than the one from which they were derived, or do we need to do test flights in still air with our own gliders?

    BTW, any suggestions for mounting the pitot tube on a powered glider?  (BoT)  I am planning on the wing, but wanted to check for opinions before I get out the xacto knife...

This reply was deleted.