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

  • Hi Sam,

    I'm in. I've just ordered a Pixhawk kit and radios that I will install in my FX-61 Phantom. I will use a FrSky DX4-ii receiver. What altimeter do I need ?

  • Thanks Fabien,

    That's a good paper, very thorough! The SG filter seems to work well. In my implementation the EKF removes the need for smoothing the vario signal as the EKF is tolerant of noise (even uses it to improve the estimate). However deciding when to start thermalling does require a smoothed estimate (in fact that's the part I'm coding/tuning right now) - I may test out the SG filter!

  • Great project !

    Have you read this paper ?

    http://www.aero.psu.edu/avia/pubs/DauLan14.pdf

    They are using an asymmetric Saviszky-Golay filter.

  • Hi Max,

    No I don't have any ailerons. It works fine with just rudder but I did have to add in some yaw damping  as it could otherwise get into a roll/yaw oscillation.

    The Radian's glide polar appears to be something like Cd = 0.026 + 0.029 * Cl^2 . I hope to get some more test glides done this weekend to confirm the accuracy of this result. Specifically I want to do some slow glides near stall and some higher speed ones (I have been doing glides between 7 and 12m/s up to now).

    Cheers

    Sam

  • Hi sam.
    Few questions: Is your radian with ailerons or not? Can you give us the radian's polar parameters?
    Cheers
    Max

  • Ok, Today i made a successfull compilation of your splendid work on arduino and on pixhawk. The last one ,has more computational power and memory. Tomorrow I'll try linux compilation.

    Let me know your work development.

    Cheers

    Max

  • Hey Max, It will compile on Windows if you use arduino from here http://dev.ardupilot.com/wiki/building-ardupilot-with-arduino-windows/ (newer gcc version) . I also found I needed to update my gcc to compile on Linux.

  • Hi Sam. 

    I'm using your release on https://github.com/samuelctabor/ardupilot/tree/Soar_lib. Have you compile it on win or linux yet?

    thanx again

    max

  • Hi Max,

    1) There are several possible ways of calculating the drag polar. You could use programs like Digital Datcom, XFLR etc.. Or you can conduct glides at different airspeeds. For a glider, the glide rate is approximately the same as the lift to drag ratio. Using the equation Cd = Cd0 + B*Cl^2, it is possible to work out the parameters Cd0 and B. Currently I am doing this calculation manually, although it may be possible to estimate it in flight in future (another EKF). I will add a guide to the wiki here https://github.com/samuelctabor/ardupilot/wiki . For now representative numbers are hard coded (I will make these parameters at some point).

    2) I am currently testing code based on 3.0.1 here https://github.com/samuelctabor/ardupilot/tree/Soar_lib

    3) McCready() returns the minimum thermal speed that the aircraft will thermal in for a given altitude. At low altitude, the aircraft should take any thermal. As it gets higher, it should ignore weaker thermals so as to improve cross country gliding speed.

    read_netto_rate() removes the aircraft sink rate from the measured climb rate to estimate the vertical speed of the air. So if the aircraft is not going up or down, the measured climb rate is zero but we know the vertical speed of the air must be positive because it is balancing the aircraft's normal sink rate. The aircraft's sink rate is calculated from the airspeed, the roll angle and the Cd0 and B drag polar coefficients.

    thermalability is the estimated climb rate of the aircraft when thermalling given the strength and radius of the thermal. Larger, wider thermals will give a better climb rate. Again, the sink rate of the aircraft must be subtracted from the updraft strength the estimate the climb rate the aircraft will achieve.

    4) I have implemented this in the Soar_lib branch (this moved nearly all functions out of mainline code into a library). You can see it in the update_vario() function here https://github.com/samuelctabor/ardupilot/blob/Soar_lib/libraries/S...

    Hope that helps

    Sam

  • Hi Sam. Good job indeed! 

    Few questions:

    1) can you describe step by step, way to compute polar for radian?

    2) Have you used code loaded on github repository? And exactly which?

    3) Can you in simple words explain McCready(float alt) function, read_netto_rate, and float thermalability?

    4) Have you implement  total aircraft energy (potential and kinetic) measeure?

    thanx in advance

    max

    p.s. of course I read all i can on maccready theory. I need only informations about informatic implementing.

This reply was deleted.