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 Trung,

    Thanks for your interest. 

    Yes you are right, the plane would begin gliding to the next waypoint if it reached SOAR_ALT_MAX at 160m with the waypoint altitude at 300m.

    If SOAR_ALT_MAX were 300m and the waypoint altitudes at 160m, the plane would climb to 160m under power at which point the TECS controller would reduce power to achieve level flight. This would then continue for the rest of the mission. While flying under power the thermal detection logic is not active as estimating the vertical air movement is more difficult than when gliding, and so the aircraft would remain in normal auto flight.

    In order to achieve what you are asking for, I think an extra parameter is needed - SOAR_ALT_CUTOFF or similar. This is the altitude at which throttle would be reduced to zero, but SOAR_ALT_MAX could be higher and remain the altitude at which thermals would be exited. 

    Does that sound like that you are looking for? It is an easy addition and I'd be happy to add that parameter to the code - recently I have been increasing SOAR_ALT_MAX as I get more comfortable flying high (I have it at 350m just now) but this does mean the climbs under throttle take a while.

    I have been doing quite a bit of testing of the thermalling code recently, here is a sneak peak. This thermal took the plane from 260m up to SOAR_ALT_MAX (350m) at a good rate of climb. The combination of wind FF and EKF centring resulted in the estimated position drifting south-west about 50m. I still have some work to do improving centring on tighter thermal (this one was pretty wide).

    3701836865?profile=original

    Cheers,

    Sam

  • 100KM

    Sam,

    This is brilliant.  Thanks so much for making this code available to test!  I have been wanting to do this for some time now.  I happen to be building a Sig Riser 100 that will now get the APM/Ardusoar treatment.  I also have a beater Easy Glider Pro that may be my initial test bed.

    I noticed you described an Auto mission with alt set to 300m, SOAR_ALT_MAX was 160m and SOAR_ALT_MIN was 80m.  If you caught a thermal while between 160m and 80m, would the plane exit the thermal at 160m and glide towards the next waypoint?  What would be the behavior if SOAR_ALT_MAX was 300m and the waypoint altitudes were 160m?

    I would like to allow the plane to gain the maximum potential energy (alt) when it encounters a thermal along a planned mission, but not to have it try to motor up to that max alt if it drops below the min alt.

    There is plenty here to get started with and test.  Just curious if the logic is already there to do what I'm describing.

    Regards,

    Trung

  • Hi Martin,

    Thanks for that info - the compass is definitely being affected by something as I receive 'Magnetometer failure' warnings from the GCS during flight. It doesn't seem to impact on navigation so I haven't done anything about it. Also I wasn't sure whether the effect of the magnets was significant compared to that of the motor and ECS below the deck. The fact that getting rid of the magnets solved your problem makes me think I should ditch the magnets, maybe I can rig something up with Dual-lock tape.

    Cheers,
    Sam
  • @ Sam Tabor.

    Hi,

    Nice solution with the plywood "deck" in the picture.

    Just a thought: I made a similar arrangement for a homemade vario and Xbee tx in my Radian a couple of years ago. But while experimenting with IMU sensors in approximately the same position, I found the magnetometer/compass was severely influenced by the "super magnets" that are meant for fastening the Radians plastic canopy. So I removed all four of them and just used painter's tape to secure the canopy, This made it much easier to calibrate the compass to a satisfying "trueness".

    Martin

  • Yes I have a FRSky vario and my Taranis setup to output the vario tones. This is not used by the soaring code (it uses APM internal baro only) but it is useful to get an idea of what the plane is sensing, and for thermalling under manual control. 

    I think the Radian Pro will make a good autonomous soaring machine! 

    Sam

  • Thanx for photo! What do You mean with vario? Have you a separate variometer?
    Max.
  • Hi Max,

    I have a plywood cover over the battery/ESC compartment. The APM, GPS, receiver and vario are mounted on it. It is held down by 3M Dual-lock (like Velco but 1000x better). There isn't a lot of room elsewhere in the Radian so I think this is the only viable solution.

    533010_ZB_00_FB.EPS_1000.jpg?width=300

    3701823213?profile=original

    Soar_lib has all the new changes. I flew again today and successfully tested the EKF in several thermals. I have gained a lot of confidence in the system and would encourage anyone interested to try it out. The only caveat is to keep an eye on the plane when in LOITER mode as it will generally head downwind quite a way. This is expected and due to the wind feedforward which helps the thermal tracking.

    I will be doing some detailed review and analysis of the logs over the next few days to see if the EKF parameters need to be adjusted.

    Cheers,

    Sam

  • very good indeed.

    I've ask about flaps, cause I make me a gift , a radian pro! I had a apm 2.6 and so.......

    Sam, where is gps placed? 

    so the last update branch is soar_lib?

    thanx again.

    Cheers Max

  • I got a good testing session done at the weekend. The week before I had seen some problems with re-entering glide after the throttle is automatically set to zero after climbout. This was due to the pitch integrator in the TECS taking too long to lower the nose back to glide trim. I added a method to the TECS to zero the pitch integrator which is called when the glide phase is entered which has eliminated this problem.

    There was some lift around in the afternoon, although it was not very strong and it was quite windy. I took the opportunity to test out the remaining parts of the code not previously run outside of simulation, which were the logic to switch into LOITER (thermal centring) mode and back, and the EKF based thermal centring algorithm. Both performed well - switching into LOITER and back into AUTO went as expected although it took a while for the decision to enter LOITER to occur - I may tweak the vario filter a bit although the log shows that the lift was just very wide and diffuse. 

    Thermal centring worked pretty much as it did in simulation - it followed the lift pretty well (considering that I have not tuned the EKF noise parameters for the real-world sensor data) and the wind feed-forward helped a lot in following the lift downwind. A couple of times the glider did get pretty far downwind and I had to bring it back under manual control. I may add a condition to avoid following lift too far off-course to avoid this situation.

    Max - I haven't done much thinking about flaps since my test plane doesn't have any (Radian) but I have thought about adjusting airspeed - the two are analogous since they both alter the lift/drag ratio. Flaps would complicate the calculation of the netto vario rate since you effectively have a different drag polar for each flap position.

    Sam

  • Has someone think about using flaps for best thermaling?

    Max

This reply was deleted.