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.