> ## 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.

# Gimbal and MAVLink camera

> Move a MAVLink gimbal at a rate from a hold-to-move pad, and take photos and zoom on a camera that speaks the MAVLink camera protocol.

Two small route groups let an operator surface drive the payload through the flight controller: a gimbal rate pad, and the photo and zoom controls of a MAVLink camera. Both need a MAVLink flight controller; on a Betaflight or iNav (MSP) flight controller they answer `501`.

Both are built so a surface that disconnects mid-move never leaves the payload moving: the agent stops the motion itself when the surface stops renewing it.

## Gimbal rate

### Is a gimbal there?

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -s -H "X-ADOS-Key: $ADOS_KEY" http://192.168.1.50:8080/api/v1/gimbal/rate
# {"available": true, "reason": null}
```

`available` needs a connected MAVLink flight controller and a gimbal attitude from it in the last 1.5 seconds. Otherwise `reason` says why: `flight controller not connected`, `this flight controller speaks MSP`, or `no gimbal reported by the flight controller`. A surface shows its pad only when `available` is `true`.

### Move it

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -s -X POST -H "X-ADOS-Key: $ADOS_KEY" -H "Content-Type: application/json" \
  -d '{"pitch_dps": -20, "yaw_dps": 0, "hold_ms": 500}' \
  http://192.168.1.50:8080/api/v1/gimbal/rate
# {"sent": true, "accepted": null, "hold_ms": 500}
```

The agent sends `MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW` to the flight controller's gimbal manager with no angle target and the two rates.

| Field | Range |
| - | - |
| `pitch_dps`, `yaw_dps` | Degrees per second, within ±180. |
| `hold_ms` | 100 to 2000, default 500. |

A surface resends while the pad is held. If no new request arrives within `hold_ms`, the agent sends a zero rate. Each request replaces the one before it. `accepted` is always `null`: the gimbal manager's acceptance is not observed on this path.

| Status | Cause |
| - | - |
| 400 | A rate or hold out of range, or not finite. |
| 501 | An MSP flight controller. |
| 503 | No flight controller, or no MAVLink connection. |

## MAVLink camera

A camera that speaks the MAVLink camera protocol (a camera component on the vehicle, or the autopilot's own camera backend) describes itself with `CAMERA_INFORMATION`. A surface lists the cameras first and drives Photo and Zoom through one when it is advertised; without one it falls back to a local frame grab and digital zoom.

### List cameras

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -s -H "X-ADOS-Key: $ADOS_KEY" http://192.168.1.50:8080/api/v1/camera/mavlink
```

Each call requests `CAMERA_INFORMATION` from every component of the flight controller's system and collects the answers for a short window. A camera that answered in the last minute stays listed, so one lost reply does not make it disappear. No flight controller, an MSP flight controller or no answer gives an empty list, never an error.

| Field | Meaning |
| - | - |
| `component_id` | The MAVLink component the camera answers from; the address capture and zoom name. |
| `vendor`, `model`, `firmware_version` | Identity. |
| `flags` | The raw `CAMERA_CAP_FLAGS`. |
| `can_capture_image`, `can_capture_video`, `can_zoom`, `can_focus`, `has_video_stream` | The decoded flags. |
| `resolution_h`, `resolution_v`, `focal_length_mm`, `lens_id` | Sensor and lens. `focal_length_mm` is `null` when the camera does not say. |
| `cam_definition_uri` | The camera definition file, empty when there is none. |

### Take a photo

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -s -X POST -H "X-ADOS-Key: $ADOS_KEY" -H "Content-Type: application/json" \
  -d '{"component_id": 100}' http://192.168.1.50:8080/api/v1/camera/mavlink/capture
```

Sends `MAV_CMD_IMAGE_START_CAPTURE` for one image.

### Zoom

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -s -X POST -H "X-ADOS-Key: $ADOS_KEY" -H "Content-Type: application/json" \
  -d '{"component_id": 100, "type": "continuous", "value": 1}' \
  http://192.168.1.50:8080/api/v1/camera/mavlink/zoom
```

Sends `MAV_CMD_SET_CAMERA_ZOOM`. `type` is one of the two zoom types ArduPilot's camera library accepts:

| `type` | `value` |
| - | - |
| `continuous` | A rate from -1 (wide) to 1 (tele); 0 stops. |
| `range` | 0 to 100 percent of the camera's zoom range. |

A zoom button sends a rate on press and 0 on release. A non-zero continuous rate holds only while the caller keeps it alive: unless another zoom or a keepalive (the same body with `"keepalive": true`) arrives within about a second, the agent sends rate 0 itself. A keepalive sends nothing to the camera, and is `409` when no zoom of that component is moving.

### Answers

Both writes answer `200` once the command was written: `{"ok", "result", "component_id"}`. `result` is the camera's `MAV_RESULT` name (`ACCEPTED`, `TEMPORARILY_REJECTED`, `DENIED`, `UNSUPPORTED`, `FAILED`, `IN_PROGRESS`, `CANCELLED`), or `TIMEOUT` when no acknowledgement arrived. `ok` is `true` for `ACCEPTED` and `IN_PROGRESS`. A status text the vehicle sent beside a refusal is attached.

| Status | Cause |
| - | - |
| 400 | Component 0, or a zoom value out of its type's range. |
| 404 | The component has not answered `CAMERA_INFORMATION`, even after one more probe. |
| 409 | The camera's flags lack the capability. |
| 501 | An MSP flight controller. |
| 503 | No flight controller, or no MAVLink connection. |


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