MAVLink Adapter
The MAVLink adapter connects to ArduPilot, PX4, and other MAVLink-speaking vehicles and streams decoded telemetry as Plexus metrics. It supports UDP, TCP, and serial connections.
Install
pip install plexus-agent[mavlink]Basic Usage
from plexus import Plexus
from plexus.adapters import MAVLinkAdapter
px = Plexus(api_key="plx_xxx", source_id="drone-001")
adapter = MAVLinkAdapter(
connection_string="udpin:0.0.0.0:14550", # SITL or GCS
)
with adapter:
while True:
for metric in adapter.poll():
px.send(metric.name, metric.value, tags=metric.tags)Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
connection_string | str | "udpin:0.0.0.0:14550" | MAVLink connection string (see table below) |
baud | int | 57600 | Serial baud rate (only for serial connections) |
source_system | int | 255 | MAVLink system ID |
source_component | int | 0 | MAVLink component ID |
dialect | str | "ardupilotmega" | MAVLink dialect |
dialect_path | str | None | None | Path to custom dialect XML file |
include_messages | list | None | None | Whitelist of message types to process |
exclude_messages | list | None | None | Blacklist of message types to skip |
emit_raw | bool | False | Emit raw message dictionaries as metrics |
emit_decoded | bool | True | Emit decoded named metrics |
raw_prefix | str | "mavlink.raw" | Metric name prefix for raw messages |
request_streams | bool | True | Request data streams on connect |
stream_rate_hz | int | 4 | Requested data stream rate in Hz |
source_id | str | None | None | Override source ID for metrics from this adapter |
Connection Types
| Format | Use Case | Example |
|---|---|---|
udpin:host:port | Listen for UDP (from SITL or GCS) | udpin:0.0.0.0:14550 |
udpout:host:port | Send UDP to a target | udpout:127.0.0.1:14551 |
tcp:host:port | TCP client | tcp:192.168.1.100:5760 |
tcpin:host:port | TCP server (listen) | tcpin:0.0.0.0:5760 |
/dev/ttyXXX | Serial port (Linux) | /dev/ttyACM0 |
COMx | Serial port (Windows) | COM3 |
Decoded Metrics
The adapter automatically decodes MAVLink messages into named metrics, including attitude (roll, pitch, yaw), GPS position, battery status, airspeed, RC channels, and more.
See examples/mavlink_basic.py for more.
Next Steps
- CAN Bus -- Read CAN bus data with DBC decoding
- MQTT -- Bridge MQTT brokers to Plexus
- CLI Reference -- Run adapters from the command line