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

  • Looks good Max.

    Added my param file here . You'll need to do some tuning though as I have the original Radian i.e. no ailerons!

    Sam

    RadianParams_101014.param
  • this is my Radian Pro. Cockpit hides electronics and pitot is under LE.

    btw Sam can you kindy give .param file?

    Cheers

    Max3701847183?profile=original

  • Yup got the drag polar.

    I have looked at speed to fly, it's pretty cool. I think it is more suited to gliders flying high and fast over long distances though where only the really strong, well defined thermals are used. The Radian is good as it has a low sink rate at 7 or 8 m/s but the glide ratio drops off quite a lot at higher speeds (lots of wing camber and too many aerials and sensors causing drag). I am going to relocate the radio antenna and airspeed sensor to reduce Cd0 which will help, but I think what is really needed is a big, streamlined ship with variable camber to enable fast cruising at a good glide ratio. Maybe its time to learn about fibreglass.3701847063?profile=original

    3701846739?profile=original

    Here's another successful thermal from the weekend, it was pretty windy (5 m/s) so it got pretty far downwind.  I have the wind estimate from the logs though so I can remove the wind drift to see what it might have looked like has there been no wind. Gained just about 80m over 90s or so. Thermalling mode was exited when maximum soaring altitude was reached at 350m.

    Actual position:

    3701847080?profile=original

    Same as above but with the wind effect removed:

    3701847123?profile=original

    3701847156?profile=original

    Cheers

    Sam

  • Aha, this is the best reason I've seen so far for getting an airspeed sensor. Free energy!

    Looks good Sam, I'd love to try it but I seriously doubt the thermalling capability of the Phantom flying wing.

    On an loosley related note, have you ever tried figuring out your drag polar? Perhaps for MacCready style 'speed to fly' calcs?

  • Just about enough lift this weekend to test the addition of SOAR_ALT_CUTOFF. This is now pushed to the github repository.

    Cheers,

    Sam

  • Hi Max,

    The APM runs the EKF fine. It is running at just 5 Hz (no point running faster than the GPS update rate) and there is no sign of slow loops.

    Cheers,

    Sam

  • Sam, have you computational problem (with EKF) with apm?

    have you nice flight!

    max

  • Hi all.

    I think that EKF can help us to tune a lot of variable.

    Max

  • No problem, I will add the parameter and test it this weekend if the weather holds up.

    Currently only the loiter target location is moved to centre the thermal, but the circling radius could also be adjusted and I have spent some time thinking about it.
    The circling radius to use to maximise climb rate depends on the thermal strength and radius, the aircraft speed and the aircraft drag polar parameters.
    The thermal strength and radius are estimated by the EKF, we know the airspeed and the drag polar parameters are needed for the vario calculation anyway. So the optimal radius can be calculated, although it is a non-linear equation so an iterative method would be needed.

    My feeling is that there are probably some gains to be made, but aggressive changes in circling radius may negate this benefit. Fortunately the EKF also gives us the covariance (error) estimate for the thermal radius as well. So circling radius could be adjusted only when the error in the radius estimate has dropped to a suitable level.

    Cheers,
    Sam
  • 100KM

    Thanks for the explanation, Sam.  Yes, SOAR_ALT_CUTOFF sounds like exactly what I had in mind.  If you think it is a worthwhile idea, I would very much appreciate the additional parameter.

    Excellent data presentation, btw.  So in thermalling mode (Loiter) does Ardusoar focus on centering the thermal, or does it also adjust the circling radius?

This reply was deleted.