Quest for the perfect flight path...

After some decent results described in my previous post regarding PID tuning for high winds:, I wanted to see what it would take to get the best possible flight path with the least amount of flight planning possible. The end result was a three waypoint 90degree corner, as shown below.



The problem of course is wind... The above path was with no wind whatsoever, as soon as high winds are added the entire thing falls apart completely, as the plane often missed the last waypoint in the downwind turns and has to circle back.


I figured that if I could get a near perfect flight path with just three waypoints on each corner, what if I went back to using a single waypoint, but simply increased the waypoint radius such that the plane had enough room to make a perfect turn. In theory this should at least be flyable in high winds without having to circle back to hit any of the waypoints...


Unfortunately this failed as well, due to what I think is the Xtrack entry angle, and possibly a bug, or at least odd behavior from my understanding.


It appears that the plane always tries to approach the path at the Xtrack entry angle after a turn, but it also always overshoots the track by a similar angle then has to correct itself. I created the following path by starting with a 90degree Xtrack entry angle at waypoint #2, then cutting that in half for each subsequent waypoint until waypoint #5 where it was 11degrees:

I can understand some overshoot after waypoint #2 (90degree entry angle), and even #3 (45degree), but #4 (22.5degree) makes no sense to me. Its such a shallow angle there should be no problem whatsoever straightening out at the track and following it right on, especially with a Xtrack gain of 225 as shown below, but Ardupilot is still pointing the plane *off* the track (based on the green line) until its well past, then it finally corrects and gets it right.



Can anyone explain why the Xtrack entry angle causes the track overshoot after every waypoint, regardless of how low the entry angle is set? Of course the major problem here is that if there is any wind at all this angle needs to be set sufficiently high enough for it to correct for the wind, otherwise the plane is hopelessly lost. 


Something seems strange to me...



Views: 2071

Comment by Alex Roup on October 27, 2011 at 6:39am

This looks like integrator windup to me.  I haven't looked at the crosstrack code in particular, but I recall that the integrator just has a fixed value constraint.  What is needed in the code is an anti-windup mode where the cross-track integrator is locked when the Xtrack entry angle limit is reached.  That way, the integrator won't be accumulating the whole time you're approaching the track, but rather only when you reach the vicinity of the trackline. 


The general rule of thumb is to lock an integrator whenever a nonlinearity is introduced into the dynamics (i.e. a limit is reached) *inside* of the location of that integrator.  In other words, lock the heading integrator when rudder (or roll command) saturates, lock the crosstrack integrator when the heading saturates, etc.  The same goes for the longitudinal loops.

Comment by Ryan Beall on October 27, 2011 at 6:45am

Ground speed is different....Same topic I alluded to in all of my other posts....

Your PID is trimmed to fly a specific set of dynamics...Well the heading change rate of an aircraft is VERY dependent upon groundspeed at these slower speeds so you have to factor it in!


Lower loops first!


Comment by Alex Roup on October 27, 2011 at 7:21am

Is the heading loop measuring heading or track made good?  If it's heading, then the heading loop and all loops inside that will be operating with respect to an air-fixed coordinate frame.  Assuming a uniform wind field then these loops (and all longitudinal loops as well) would be unaffected by ground speed or wind speed and their dynamics would only vary with airspeed.  The crosstrack loop is referenced to the ground coordinate frame and therefore its dynamics will change with ground speed.

Comment by Alexander Malikov on October 27, 2011 at 7:37am

You should think about throwing heading loop out. Best result gives navigation loop over roll loop. Navigation loop is roll_setpoint = xte * k1 + dxte * k2, where "xte" is crosstrack error (should be limited to avoid circling far from path), "dxte" is xte derivative. You can also substitute "dxte" by a * w, where "a" is angle in radians between path vector and ground speed vector, "w" is ground speed module. Then tune k1 and k2. And of course use turn prediction.

Comment by Alexander Malikov on October 27, 2011 at 7:42am

You can start from k1 = 0.3 and k2 = 3. Roll limit = 30°. Xte limit = 500m.

Comment by The Old Flyer on October 27, 2011 at 3:20pm


Assuming the Servo and Nav PIDs are adjusted good HIL flight paths can be achieved if you adjust the WP Radius to the turn radius of the aircraft, and reduce the Xtrack gain to 10 or below.

Here are my results:

I then set the wind to be 12K from the Northwest, adjusted the Xtrack gain to 2 with this result:

The bigger WP Radius and much lower Xtrack gain made all the difference for me.

Hope this helps.

Comment by Mike on October 27, 2011 at 4:00pm

Irvin: See my previous blog post about high winds:


Its highly unlikely that you would be able to land your plane in those winds as your track error is wider than the airport runway in your screenshots. My eventual goal is to be able to auto land my plane on a dirt road, much narrower than any runway, with trees on either side, but still easily doable with decent track following. This is not a problem at all with no wind, but in the mountains having no wind is like finding a pot of gold at the end of a rainbow. ;)


Lowering the Xtrack gain doesn't appear to be the solution to my problem... Though I would be curious to see your PIDs either way.

Comment by The Old Flyer on October 27, 2011 at 4:36pm


How about multiple WPs in line even before you start the decent.

Can you land the plane manually under the conditions you described?  If so - APM should be able to too.

A very interesting project.  We will be flying the Telemaster along a cliff edge with the runway 90` to the prevailing wind.  It would be nice to "AutoLand it.


Here are my PIDs:

Comment by Mike on October 27, 2011 at 4:57pm

Irvin: I can definitely land the plane in those conditions manually, as I have had to many times in the past when my Ardupilot attempts failed. They definitely weren't all pretty landings though, thats for sure. In theory Ardupilot should be able to land (and fly) the plane better than most pilots, as I don't know many pilots with a constant 10hz response rate. ;)


I've tried multiple waypoints all the way to the final landing waypoint, no more than 100m or so apart and even moderately gusty wind foiled my plan everytime.


As mentioned above in this blog post, setting so many way points like that *especially on final approach* is a recipe for disaster in high winds, because when your 10-20m off the ground with trees near by, and the plane misses a waypoint, it can often try to circle directly into a tree, or even small hills at that altitude. Or even worse it doesn't have the altitude or airspeed to circle at all. Increasing the waypoint radius also doesn't help, as that introduces potential error, 30m radius on your waypoints is already wider than most places I have available for landing.


Having less waypoints and better track following is much safer way to go... If it can work...


The screenshots of your flight path, what airframe were you using?

Comment by Squalish on October 27, 2011 at 5:02pm

We've also experimented with high winds, and found that downwind is particularly challenging because of overshoot problems and speed differentials.

I think Irvin has the right idea for low-wind situations right now, but it seems like this is something that should be handled by extending the concept of point-to-point navigation, to include 'Turning zones' or 'Waypoint Areas' that integrate exit directions, or a point with a narrow 'Aim here' circle, but a wider 'Don't turn back' circle, or perhaps something that varies roll angle with wind.  It should be relatively transparent to the user what is happening.

Think of what you actually need to do with a medium-FL side-looking camera to circle a ground target and maintain camera-on-target, with realistic wind conditions.  Hundreds of manually-selected waypoints?

Before tackling that, I would just like to be able to tell APM "I need this line, this line, and this line to be flown very precisely beginning to end with a low yaw/pitch/roll variance & no loops, and I don't care what the autopilot does to in order to get at that angle, measure/correct for the wind, or navigate itself from the end of line A to the beginning of line B".  Is this codable?


You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service