> ## Documentation Index
> Fetch the complete documentation index at: https://docs.altnautica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ADOS Pilot

> The on-board command authority: who flies the drone, the pilot stream an operator surface connects to, its actions, obstacle handling, planners and config.

`ados-pilot` is the drone's on-board command authority. While the control mode is `ados`, it is the only thing that produces motion setpoints. It shapes operator sticks into velocity and hold setpoints, runs skill goals, map gotos and swarm goals through its obstacle planner, applies the geofence and failsafes, and streams `SET_POSITION_TARGET_LOCAL_NED` to a flight controller flying GUIDED.

The flight controller keeps stabilisation, the EKF, mixing and its own last-resort failsafe, which watches the pilot's heartbeat. The pilot never replaces the flight controller; it decides what the flight controller is asked to do.

`ados-pilot` is a core service on the `drone` profile. It runs a 50 Hz decision loop and talks to the rest of the agent over its own socket, `pilot.v1`.

## Control modes

`control.mode` in the agent config decides where operator sticks go.

| Mode | Sticks go to | Flight controller mode |
| - | - | - |
| `ados` (default) | The pilot, which shapes them into setpoints | GUIDED |
| `fc_manual` | The flight controller, as `MANUAL_CONTROL` from the ground | The operator's choice |
| `elrs` | The flight controller's RC input, through the ground station's ELRS link | The operator's choice |

An operator surface can change the mode at run time with the `control_mode:<mode>` action. The pilot persists the change back into `control.mode`.

## Who commands motion

Exactly one owner commands motion at a time. The pilot publishes the current owner in its state.

| Owner | Meaning |
| - | - |
| `idle` | Nothing commands motion. |
| `pilot` | Operator sticks, shaped by the pilot. |
| `skill` | An extension's skill holds the motion lease and sends goals. |
| `goto` | A map point an operator picked. |
| `swarm` | A swarm goal. |
| `mission_fc` | The flight controller flies its own mission. |
| `fc_mode` | The flight controller flies a mode it was handed (Loiter, for example). |
| `tuning` | An [aircraft setup](https://docs.altnautica.com/drone-agent/fc-setup.md) air step is flying. |

A skill holds a motion lease. A lease that sends no goal for one second is revoked.

## The pilot stream

Operator surfaces (Mission Control's Flight tab, the Android GCS cockpit, the on-box cockpit) connect to one WebSocket:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
WS /api/v1/pilot/stream
```

A browser authenticates with a ticket for scope `pilot.control`: call `POST /api/_ws/ticket` with `{"scope": "pilot.control"}` and the pairing key, then open the socket with the subprotocols `["ados-ws-ticket", <ticket>]`. A native client passes `X-ADOS-Key` on the handshake. MCP tokens never receive this scope.

### Frames from the agent

| Frame | When |
| - | - |
| `{"kind": "pilot", "ts_ms", "data"}` | The pilot's state, 10 times a second. |
| `{"kind": "action_result", "name", "id", "ok", "err"}` | Once per action, with the pilot's answer. |
| `{"kind": "keepalive", "ts_ms"}` | Once a second when nothing else was sent. |
| `{"kind": "error", "err": "pilot_unavailable"}` | The pilot is not running. The socket then closes. |

`data` carries, among others: `owner`, `control_mode`, `profile`, `avoid`, `fc_mode_name`, `armed`, `landed`, `input_src` and `input_age_ms`, `hold_reason`, `avoid_state`, `min_clearance_m`, the planned path (`plan_ned`), the `readiness` list, the link-loss action and countdown, mission progress, the active banner and `surface_ops` (the operations a surface may offer right now). The same body is the `pilot` kind on the navigation stream (`WS /api/v1/nav/stream`).

### Frames from a surface

Each frame is JSON with an `op`, the surface name in `src` and the surface instance id in `sid`. The stream accepts only these ops; any other op is answered `unknown_op`.

| `op` | Purpose | Fields |
| - | - | - |
| `input` | One stick frame | `session`, `seq`, `t_ms`, `axes` `[roll, pitch, thr, yaw]` each in `[-1, 1]`, `buttons` (bitfield) |
| `session.take` | Take stick input for a new session | `session` |
| `release` | Release the sticks | `session` |
| `hb` | Heartbeat | none |
| `bye` | The surface is leaving | none |
| `action` | Run a named action | `name`, optional `args`, optional `id` echoed in the result |

Axis signs: pitch positive is forward, throttle positive is climb, yaw positive is clockwise, roll positive is right. The surface applies its own stick mode mapping and dead zone before it sends.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"op": "action", "src": "mc", "sid": "0f1e2d3c4b5a69788796a5b4c3d2e1f0",
 "name": "goto", "args": {"lat": 47.3977, "lon": 8.5456, "alt_m": 25}, "id": "4"}
```

### Actions

| Action | Effect |
| - | - |
| `arm`, `disarm` | Arm, or disarm once landed. |
| `takeoff` | Arm and climb (`args.alt_m`, 1 to 120 m), then hold. |
| `launch` | A take-off followed by a hold, a skill, a mission or a goto. |
| `land`, `rth`, `pause`, `resume` | Land in place, return home, brake and hold, resume a held mission. |
| `rth_cancel` | Cancel a low-battery return countdown. |
| `take_control` | Hand motion to the operator's sticks. |
| `hand_to_fc` | Give the flight controller a mode (`args.mode`, default `loiter`). |
| `goto` | Fly to `args.lat`, `args.lon`, `args.alt_m` through the planner. |
| `mission_skip` | Skip the current mission item. |
| `kill` | Emergency motor stop. |
| `profile:<cine\|normal\|sport>` | Change the stick profile; persisted. |
| `avoid:<brake\|bypass\|off>` | Change obstacle handling; persisted. |
| `place_class:<open\|confined>` | Change the place class; refused while armed. |
| `control_mode:<ados\|fc_manual\|elrs>` | Change the control mode; persisted. |
| `vtol:<fw\|hover>` | VTOL transition: `fw` flies forward (CRUISE); any other value hovers (QLOITER). |

An unknown action answers `unknown_action`. A malformed frame answers `malformed`.

## Obstacle handling and planners

`pilot.avoid` sets what the pilot does near obstacles: `brake` (stop and hold, the default), `bypass` (route round them) or `off`. The margin is `pilot.obstacle_margin_m` in an open place. In a `confined` place (mines, tunnels, rooms) the pilot keeps `pilot.prop_tip_radius_m` plus 0.1 m clear, checks the mission route, and caps speed near walls.

Two planners can fly skill goals and gotos, chosen with `pilot.planner`:

| `pilot.planner` | Behaviour |
| - | - |
| `reactive` (default) | A grid planner: the goal while its way is clear, otherwise a detour spot on the skill's ring found with A\* over the clearance grid. A goto it finds blocked follows the trajectory planner's route. |
| `trajectory` | A smooth trajectory replanned at 10 Hz, committed only with a backup that stops in seen-free space. |

`pilot.planner_shadow: true` also runs the trajectory planner beside the reactive one for skill goals and publishes its plan as a shadow that is never flown, so you can compare the two. It costs a full trajectory search every replan, so it is off by default.

## Link loss and stalls

If no surface frame arrives for `pilot.link_loss_s` seconds, the pilot runs `pilot.link_loss_action` (`rth`, `hold` or `land`) and shows the countdown in its state. With an RC transmitter, any surface frame refreshes one shared timer. With no RC transmitter, each surface instance (`sid`) has its own timer, so a second surface never hides the loss of the first; an instance leaves the watch only through a `bye` sent while disarmed or while another instance holds the sticks.

A mission waypoint that comes less than `pilot.stall_min_progress_m` closer in `pilot.stall_window_s` holds the vehicle and alerts the operator; the `stall_*` keys set when it is skipped and when a confined mission returns home on its own.

`pilot.rc_receiver: absent` declares flight with no RC transmitter. It is accepted only under ADOS control on ArduCopter in an open place, and the pilot then caps distance from home at 50 m and height at 40 m.

## Configuration

The `pilot` section of `/etc/ados/config.yaml`:

| Key | Type | Default | Allowed | Description |
| - | - | - | - | - |
| `pilot.avoid` | string | `"brake"` | `"brake"`, `"bypass"`, `"off"` | Avoid |
| `pilot.fc_sensors.flow.orient_yaw_cdeg` | integer\|null | n/a | -17999 to 18000 | Orient Yaw Cdeg |
| `pilot.fc_sensors.flow.pos_m` | array\|null | n/a | n/a | Pos M |
| `pilot.fc_sensors.rangefinder.pos_m` | array\|null | n/a | n/a | Pos M |
| `pilot.gnss_denied_max_accel_mps2` | number | `1.5` | 0.5 to 6 | Gnss Denied Max Accel Mps2 |
| `pilot.gnss_denied_max_speed_mps` | number | `2` | 0.5 to 15 | Gnss Denied Max Speed Mps |
| `pilot.height_ref` | string | `"agl"` | `"agl"`, `"ekf"` | Height Ref |
| `pilot.link_loss_action` | string | `"rth"` | `"rth"`, `"hold"`, `"land"` | Link Loss Action |
| `pilot.link_loss_s` | integer | `10` | 3 to 120 | Link Loss S |
| `pilot.low_battery_countdown_s` | integer | `10` | 5 to 30 | Low Battery Countdown S |
| `pilot.max_alt_agl_m` | number | `120` | 5 to 500 | Max Alt Agl M |
| `pilot.max_dist_m` | number | `500` | 20 to 10000 | Max Dist M |
| `pilot.max_pose_sigma_m` | number | `5` | 1.5 to 50 | Max Pose Sigma M |
| `pilot.min_agl_fw_m` | number | `30` | 10 to 300 | Min Agl Fw M |
| `pilot.obstacle_margin_m` | number | `1.5` | 0.5 to 5 | Obstacle Margin M |
| `pilot.place_class` | string | `"open"` | `"open"`, `"confined"` | Place Class |
| `pilot.planner` | string | `"reactive"` | `"reactive"`, `"trajectory"` | Planner |
| `pilot.planner_shadow` | boolean | `false` | n/a | Planner Shadow |
| `pilot.profile` | string | `"normal"` | `"cine"`, `"normal"`, `"sport"` | Profile |
| `pilot.prop_tip_radius_m` | number\|null | n/a | 0 to 3 | Outermost rigid extent from the CG in the body x-y plane, metres: the largest of the propeller tips, guards or cage, and rigid mounts (a guarded or caged frame enters the guard radius). The obstacle brake keeps it clear (0.4 m when unset); a confined place requires it and keeps it plus 0.1 m. |
| `pilot.rc_receiver` | string | `"present"` | `"present"`, `"absent"` | Rc Receiver |
| `pilot.return_blocked_land_after_s` | integer | `45` | 15 to 300 | Return Blocked Land After S |
| `pilot.stall_max_auto_skips` | integer | `2` | 1 to 5 | Stall Max Auto Skips |
| `pilot.stall_min_progress_m` | number | `1` | 0.5 to 5 | Stall Min Progress M |
| `pilot.stall_return_after_s` | integer | `45` | 15 to 300 | Stall Return After S |
| `pilot.stall_skip_after_s` | integer | `45` | 15 to 300 | Stall Skip After S |
| `pilot.stall_window_s` | integer | `15` | 10 to 60 | Stall Window S |
| `pilot.supervised_liftoff` | boolean | `false` | n/a | Supervised Liftoff |

Three more keys sit in the same section: `pilot.planner` (`reactive` or `trajectory`, default `reactive`), `pilot.planner_shadow` (default `false`) and `pilot.max_pose_sigma_m` (default `5`, 1.5 to 50: the external position's one-sigma horizontal uncertainty above which the pilot treats it as unverified). See [Configuration](https://docs.altnautica.com/drone-agent/configuration.md).

## Related

> [card] [Aircraft setup](https://docs.altnautica.com/drone-agent/fc-setup.md)
>
> The setup and tuning wizards the pilot runs.

> [card] [Swarm bus](https://docs.altnautica.com/drone-agent/swarm-bus.md)
>
> The position beacon every drone hears, with no ground station in the path.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.