title_body: What are the available solutions for creating complex user-defined UAV behavior in autopilots? Most freely available autopilot-enabled flight control hardware and firmware for hobby/consumer-grade UAVs seem to have a rather fixed feature set. There are usually varying degrees of stabilization, position hold/loiter modes, automatic takeoff and landing, return to home and a waypoint-following "mission" mode, but little beyond that. There are sometimes specialized modes such as thermal soaring and terrain following. However, all of these are pre-programmed and non-extendable, by which I mean that there is no way (at least I could find none) for a user to program their own custom flight logic, e.g. via scripting. I may have missed this, though.
  
  So, Is there, in any of the autopilot solutions currently available to hobbyists, a way for a user to define their own flight logic without rewriting the autopilot software itself, by instead building on top of existing software?
  
  To be clear, I'm looking for a way to write logic outside of the main flight control/autopilot package, either via some kind of scripting engine native to the autopilot or as a program running on a device parallel to the autopilot that can communicate to it and get the necessary flight information/send commands.
upvoted_answer: I think your best bet would be Ardupilot. The communication protocol it uses, called MavLink, is documented and easy to use. Connect to the UART with an Arduino and you will have full control over the UAV.
  
  There is even an Arduino library and a bunch of examples, like this forum post, of people doing exactly what you are looking to do. I did this once because I needed to grab the GPS and Compass information for a work project. You can research the various mission control programs that use MavLink to see the extent of control the protocol has. If I remember correctly you can even send direct stick commands over that interface to manually pilot the craft. This solution makes for lots of flexibility, especially when you consider the huge community writing Arduino libraries. It would be simple to add just about any sensor you could want.