Adapters
MAVLink

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

ParameterTypeDefaultDescription
connection_stringstr"udpin:0.0.0.0:14550"MAVLink connection string (see table below)
baudint57600Serial baud rate (only for serial connections)
source_systemint255MAVLink system ID
source_componentint0MAVLink component ID
dialectstr"ardupilotmega"MAVLink dialect
dialect_pathstr | NoneNonePath to custom dialect XML file
include_messageslist | NoneNoneWhitelist of message types to process
exclude_messageslist | NoneNoneBlacklist of message types to skip
emit_rawboolFalseEmit raw message dictionaries as metrics
emit_decodedboolTrueEmit decoded named metrics
raw_prefixstr"mavlink.raw"Metric name prefix for raw messages
request_streamsboolTrueRequest data streams on connect
stream_rate_hzint4Requested data stream rate in Hz
source_idstr | NoneNoneOverride source ID for metrics from this adapter

Connection Types

FormatUse CaseExample
udpin:host:portListen for UDP (from SITL or GCS)udpin:0.0.0.0:14550
udpout:host:portSend UDP to a targetudpout:127.0.0.1:14551
tcp:host:portTCP clienttcp:192.168.1.100:5760
tcpin:host:portTCP server (listen)tcpin:0.0.0.0:5760
/dev/ttyXXXSerial port (Linux)/dev/ttyACM0
COMxSerial 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