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

  • @thomas,

    thanks!

    yes, the weather outside is shit. having some more time to complete my softtware.

    will try to lift my foamie this summer.

  • Hi nice to have you here,

    @Trung same here didn't started yet with my "big one", I think it's mandatory for detecting thermals efficiently but maybe Sam could explain futher.

    @Robert the polar is the "performance value" of a wing / plane in conjunction of lift, drag it depends on airfoil wingspan/shape/angles - this is what I get the last days - maybe Sam could explain further too ;) he uses 3 polar parameters in the code:( pasted from Github )

    The drag polar parameters SOAR_POLAR_B, SOAR_POLAR_K and SOAR_POLAR_CD0 allow the aircraft sink rate to be calculated from a given airspeed and bank angle (netto compensation).

    This week should be very bad rainy weather so I start building the Natschalnik.

    3701989654?profile=original

  • @trung

    hi, i am new to this.

    a simple/short explanation about "glide polar" would be very helpfull.

  • 100KM

    Thomas, the B.o.T. also comes as a ARF from Tower Hobbies.  (though typically heavier than the kit version)  Sadly, I still have not completed my "ARF".  How critical is knowing your specific glide polar for the code to work?

  • Hey Sam, nice one thanks a lot ! I'll try the code after finished some interior construction in the attic to get my wife pleased ;)  could you please post your polar values for the radian -I have only 1.6m wingspan and smaller chord ( 14.5 cm) with weight of approx 750g on the testing glider butseems to be in scale like radian pro, don't know the airfoil something flat on downside but could be a good starting point.

    What about your bird of time ? I've taken a look at it during search for a good thermal glider but decided to get the natschaltnik because of faster building process ;)

    cheers ( with 3rd beer ;) ) maybe we get connected via G+

  • Hey Thomas,

    Yes for finding the polar I do some glides at different airspeeds, work out lift and drag ratios and a best fit drag polar curve. 

    Looks like the release versions are marked by tags, so I should be able to merge in.

    Sorry, that was an issue with the code that I experienced and fixed but neglected to push to the github repository. I've updated that now and put up new binaries on google drive.

    Cheers!

  • Hi Sam,

    for the untagged stable release code I would try next week to extract a set of differences by difftool between releasecandidate and stable verison maybe it helps?  

    Yes your "parameterset" solution is the right aproach ( I didn't think of polar changing in flapcondition) unfortunatly is hard for me to get the translation into german of some technical terms and formula symbols but I'm working on it ;)

    Last flight on sunday I give a try with the soaring code enabled:

    - TECS_SPDWEIGHT not set to 2.0 ( kept in default? my fault - read,understand,fly ;) )

    - waypoints between Soar min / max ( my fault - read,understand,fly ;) ) 

    - no airspeed sensor on board ( now I installed my only one.. - have to order second ;) )

    - left soaring polar-parameters to default ( have to find out right ones but don't know exactly how, downloaded xflr5 and give it a try, testflights must be in unwindy condition maybe today in late afternoon 6kph by weather.com ;) )

    In auto mode there happen something strange: after 2 waypoints the APM went to RTL and I couldn't change the mode neither with transmitter nor GCS until I change the soaring_active parameter during flight to 0, is there some failsave action for any circumstance in the code ?

  • Hey Thomas,

    Nice one, I've used autotune on my new glider and it works really well. It used to be a real pain to get the PIDs set using the GCS.

    I have been wanting to do flaps too, it has a lot of potential to get a faster glide between thermals with a good glide ratio. The only difficulty is that the glide polar of the plane is used to work out what the air is doing, and the polar will change with flap setting. I think the way to do it would be to have a set of glide polar parameters for each flap setting, and use the corresponding setting. Currently this isn't implemented, but it wouldn't be too difficult to add.
    The other option would be to have one polar, which includes the effects of the varying flap deflection (an 'effective polar'). See below (polar curves are made up). In this case the flaps would be deployed to a position for any airspeed to give the best L/D. However, the flap deflection would need to be a smooth function of airspeed to avoid discontinuities in the 'effective polar', rather than current approach of three discrete positions. This might be a more long term goal!3701988332?profile=original

  • Hi Sam i've i spend some time to get familar with the arduplane stuff. In my testing plane(1.6m bixler like soaring formiert) realy fantastic project! Actually I did autotune and some waypoint flights next step would be to enable soaring code and go further with thermaling. I've read that there is a do_Change_speed command wich could be Used to set the target speed in soaring mode, I believe that would use the autoflap speed 1 / 2 feature, how do you feel about this? Cheers Thomas!
  • Hi Sam, thank for fast reply and the update, i've an "natschalnik xl" from http://www.ostflieger.de additionally I'am on a good way with an odroid w for wifi, cam, 3g telememetry and logging. I'm planning and hoping to make some long distance thermal flights with this setup.
This reply was deleted.