This article is part three in a series, describing some of the inner workings of an autopilot system - even though the description is specific for this particular system, a lot of principles are generic and can be used to describe a variety of auto pilot systems.
Today we take a look at the maneuver system.
For each type of vessel, there is a library of maneuvers. Some are common for all vessels and some are specific for a specific type of vessel or configuration.
A maneuver can either be of a simple nature, like turning right until another maneuver is issued by the autopilot, or a more complex maneuver that has some logic embedded (timing etc.) or is changing flight path dynamically based on data from sensors etc…
A maneuver can be synchronous or asynchronous, meaning that it either does something quickly (ie: issue a roll correction command) then terminates, or it does something that takes a while (ie: navigates the drone to a waypoint) which it does in it’s own thread and reports back to the main system when it’s finished. Asynchronous maneuvers has a built-in kill switch, which can be activated by the autopilot if certain conditions arise - ie. the rangeguard system triggers, the statemachine wants to change state etc., or the maneuver simply takes too long to execute. Maneuvers can also be temporarily paused.
Example - The simple maneuver
Suppose the drone is in the air and you’ve just activated the freeflight mode (which means that the drone is controlled manually by the operator). If you issue a turn left command, the system issues a turn left maneuver. Since the maneuver only does one thing, send a left flap down, right flap up command to wing servos, the maneuver is considered simple and only takes a few milliseconds to perform. The drone starts to turn and will continue to do so until the operator issues another command or the auto-part of the autopilot takes over for some reason.
The advanced maneuver
Once it’s time to get the drone safely back to earth (and we are talking a flying wing here), the autoland maneuver is executed. This maneuver could be a simple turn-off-the-engine-and-lets-hope-for-the-best type of thing, but I’ve made it a bit more dynamic.
The strategy is to let the maneuver store the planes heading and try to keep that heading all the way until the plane has landed. Furthermore we want to keep the engine running (a little bit) until we are a few meters over ground to have some thrust for steering.
The maneuver is asynchronous, because we want it to terminate when the plane is safely on the ground and the state machine can transcend to the safe state.
The maneuver starts by subscribing to the telemetry coming from the plane sensors. This ensures that each time the telemetry is updated, the autoland maneuver is fed the new data.
The maneuver then stores the current heading and locks in on it, by applying correctional turns if the plane starts to point off that heading with more than 10 degrees.
At the same time it tells the engine to spin slowly (approx. 15%).
Then it waits for the altimeter to tell it that it has sunk below 2 meters altitude. When it does, it turns off the engine completely but keeps applying correctional turns if the plane starts to head outside it’s chosen heading.
The maneuver also listens to the gyros and accelerometers. When no forward motion is detected for a period of time (a few seconds), the maneuver considers it’s job done, and issues a maneuver done signal back to the main system, which will trigger the state machine to change to safe mode.
One curiosity is that maneuvers can utilize other maneuvers to get their job done, ie. the general "flying through waypoints" maneuver, uses the simpler "fly to one waypoint" maneuver to get to each waypoint.
Initial flight testing, log analysing and optimization