Friday, June 13, 2008

Progress!

So, I've been working on the autopilot for the last few days, now that my undergraduate classes are over. Since my last post, I've managed to make a fair bit of progress.

A brief rundown of changes to my autopilot:
--lowered the saturations to ~+/- 40-50 degrees for each control surface and 0.1-0.5 throttle
--added an airspeed hold function based on the altitude hold
--created a desired heading -> desired bank angle function
--created a desired GPS location -> desired heading function

Bumping the saturations down is helping a fair bit. The airplane doesn't try to do too many stupid things now--like try to deflect the elevator so much that it goes unstable. But it still has this funny problem where the steady state aileron command during level flight is nonzero (and negative). I haven't figured out what's causing it yet...but it's being annoying. Fortunately, it's not affecting the results too much (I think). The airplane model still reacts in a fairly sensible-looking manner.

The airspeed hold is a bit of a question mark. We need to figure out how better to integrate it into our command structure. Like...when speed command is issued, give it priority or something.

Jerry worked out the basic heading -> desired bank angle algorithm earlier in the month, but I wasn't able to incorporate it into the autopilot until this afternoon. We were encountering a problem having it turn left, however; it would simply refuse to do so, and dive into the ground when given a command to turn in that direction. Several hours of debugging later, I noticed that our preset ranges for sideslip angle were wrong; it was [0 10] degrees...and not something like [-20 20]. Changing that fixed our problem.

I also worked out the math for the GPS coordinates -> desired heading function. Given a starting GPS location and GPS coordinates for a waypoint, I can issue a command to track that point. The airplane will then turn and attempt to reach that point. Here's a nifty plot of my initial test of this function:

The airplane starts at the red circle and attempts to reach the black diamond. As you can see, it misses the waypoint and gets confused; subsequently, it begins to circle about that point in an attempt to reach it.

Very rudimentary...but it's a great proof of concept. I'm pretty excited about it, anyway. The next step from here is to set up some more control logic so that the airplane has a preset default command in the event that no waypoints can be found. For example, it could just level itself out after reaching a waypoint. But perhaps my only disappointment is that I'm graduating; next year, I'll have to leave this work to someone else. Maybe I should try to finish as much of this as I can....