Skip to content

About

View-only MAVLink telemetry relay for ArduPilot and PX4. One Python file, standard library, outbound WSS only.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

RotorLab relay agent: live, view-only MAVLink telemetry to your team, with no inbound port.

Latest release License: Apache 2.0 Python 3.8 or later Dependencies: none, standard library only View-only toward the flight controller

RotorLab relay agent

Watch a MAVLink aircraft live from anywhere, without opening a single inbound port.

  • One file, nothing to install. About 550 lines of standard-library Python 3.8 or later that you can read in one sitting.
  • View-only by construction. The serial port opens read only, no local link has a write method, and anything the relay sends down the link is dropped.
  • Outbound only. The aircraft needs no public address, no port forward and no VPN: the agent dials out over WSS (TLS) on port 443.
  • Your organization's key, not a person's. Each aircraft signs in with its own revocable device key, so one lost computer is one key to revoke.
  • Built for the field. It reconnects on its own, caps the data it holds when the link is slow, and runs as a hardened systemd service.

Quick start | Open Live Telemetry | Documentation | Talk to sales

It runs beside an ArduPilot or PX4 flight controller (or any MAVLink source), reads the telemetry stream and sends it to the RotorLab cloud relay. Members of your RotorLab organization watch the aircraft on the Live Telemetry page in a browser. The agent never sends anything back to the flight controller. RotorLab records and shows; it does not authorize or control flights.

The RotorLab Live Telemetry page connected through the cloud relay to the demo aircraft DEMO-01: the agent status reads online, with the attitude indicator, heading, battery, throttle, altitude and groundspeed updating live.
Live Telemetry watching the demo aircraft DEMO-01 through the cloud relay. Fictional demo organization and data.

Contents

Who it is for

  • Drone programs and program leads, including public safety and inspection teams, who need to see an aircraft that is flying somewhere else: a crew in the field, a test range, a customer site.
  • Builders and integrators with a companion computer (a Raspberry Pi or similar) on board, or a ground-station box next to the radio.
  • Engineering and test teams running SITL or a bench aircraft who want the same live view without opening a port on the lab network.

You need a RotorLab organization with Live Telemetry, and someone in it who can create a relay device key.

How it works

flowchart LR
    FC["Flight controller<br/>ArduPilot, PX4 or any MAVLink source"]
    R0["mavlink-router, MAVProxy<br/>or SITL (optional)"]
    A["RotorLab relay agent<br/>companion computer or ground box"]
    R["RotorLab cloud relay"]
    V["Members of your organization<br/>Live Telemetry page"]
    FC -- "serial, read only" --> A
    FC -- MAVLink --> R0
    R0 -- "UDP or TCP, read only" --> A
    A -- "WSS on port 443, outbound only<br/>Authorization: Bearer rlrd_..." --> R
    R -- "live view, signed-in members" --> V
    R -. "keepalive and close frames only" .-> A
Loading
  • The agent reads MAVLink from one local source: a UDP endpoint, a TCP endpoint or the flight controller's serial port.
  • It gathers what it reads for 200 ms and sends it as one message, so it sends at most five messages a second.
  • The only connection it opens to the internet is the outbound WebSocket to the relay. Nothing needs to reach in.
  • It does not decode, filter or store your telemetry: it forwards the bytes it reads.
  • It keeps the link up: it answers the relay's keepalive, pings the relay every 20 seconds, and reconnects with backoff (1, 2, 4 seconds and so on, up to 30) when the link drops.
  • It stops on its own when the relay ends its link because the key was revoked, and steps back for a minute or more when another agent is using the same key.

The full picture, including what the relay may and may not send, is in docs/security-model.md.

What this is not

The relay agent is for watching. It is not a ground control station, a command link or a safety system, and live view depends on your network and the cloud relay, so it can lag or drop. Fly with your ground control station and your procedures, and use the Live Telemetry page as an additional view for people who are not at the aircraft.

Quick start

1. Create a device key

In RotorLab, open Live Telemetry (https://app.rotorlab.app/fc), open Cloud relay setup, name the device after the aircraft and click Create device key. Copy it now: it is shown once, and RotorLab keeps only a hash of it. The card also shows a ready-made command with your key in it; for a computer you keep, prefer the environment file in Run it as a service or read -rs ROTORLAB_DEVICE_KEY && export ROTORLAB_DEVICE_KEY, so the key stays out of your shell history. Creating keys needs the right permission in your organization; if you do not have it, ask an organization administrator.

The Cloud relay setup card on Live Telemetry: a device key for DEMO-03 has just been created and is shown once, masked here, followed by the download link, the commands to run the agent over UDP, TCP or serial, and the list of the organization's relay devices with a Revoke button for each.
Cloud relay setup right after a device key is created. The key in this picture is masked.

2. Get the agent

Download rotorlab_relay_agent.py and SHA256SUMS.txt from this repository's Releases page, or clone the repository. Check the file as described under Verify the download.

3. Put the key in the environment

Paste the key at the prompt and press Enter, so it never lands in your shell history or the process list.

Linux or macOS:

read -rs ROTORLAB_DEVICE_KEY && export ROTORLAB_DEVICE_KEY

Windows PowerShell (UDP and TCP modes):

$env:ROTORLAB_DEVICE_KEY = Read-Host "Paste the device key"

4. Run it against your MAVLink source

UDP, from mavlink-router or MAVProxy (the default). The agent listens on a port of its own and needs an endpoint that sends to it: a mavlink-router server-mode UDP endpoint or a MAVProxy udpin output. It sends to 127.0.0.1:14550 and reads what comes back.

With mavlink-router, add a server-mode UDP endpoint to its configuration (for example /etc/mavlink-router/main.conf):

[UdpEndpoint relay]
Mode = Server
Address = 127.0.0.1
Port = 14550

Or with MAVProxy, add a udpin output:

mavproxy.py --master=/dev/ttyAMA0 --baudrate 921600 --out=udpin:127.0.0.1:14550

Then start the agent:

python3 rotorlab_relay_agent.py --udp 127.0.0.1:14550

In UDP mode the agent takes telemetry only from the host you give in --udp and ignores datagrams from any other address. When that host is this computer (127.0.0.1, the default), the agent listens on the loopback interface only, so nothing off the machine can reach it. Keeping the UDP endpoint on the same machine is the recommended setup. If the link to RotorLab is slower than the telemetry, the agent keeps the newest data within a fixed limit and logs once that it is dropping the oldest.

TCP, for SITL or a TCP server output. ArduPilot SITL serves MAVLink on TCP port 5760.

python3 rotorlab_relay_agent.py --tcp 127.0.0.1:5760

On Windows, use python (or py) in place of python3.

Serial, straight from the flight controller (Linux and macOS). On a Raspberry Pi wired to the flight controller's telemetry port:

python3 rotorlab_relay_agent.py --serial /dev/ttyAMA0 --baud 921600

Serial mode needs the port to itself. If MAVProxy, mavlink-router or a ground station already uses the port, do not use --serial: use --udp or --tcp from that program instead. Set --baud to the flight controller's telemetry speed. The user running the agent needs read access to the port, usually by being in the dialout group (sudo usermod -aG dialout $USER, then log in again). On a Raspberry Pi, the serial console must be off for the port to be free.

5. Watch it

Open Live Telemetry, choose RotorLab Cloud relay under Connection, pick the device, watch its Drone agent status turn online, and click Connect. The page works on a phone too.

Live Telemetry on a phone, connected to the demo aircraft DEMO-03 over the cloud relay, with the agent online and the attitude indicator and heading below.

The readout below the instruments (link, power, attitude, GPS and a flight summary) is in docs/images/live-telemetry-readout-light.png and its dark version.

What a run looks like

These are real runs of this release's rotorlab_relay_agent.py, made on Windows 11 with Python 3.14 against a throwaway RotorLab server on the same computer. The source was a synthetic SITL-style MAVLink stream on TCP. Because the server was on this computer, the address was a plain ws://127.0.0.1 one, which the agent accepts only for this computer; against RotorLab you leave --url at its wss:// default.

A link that comes up, survives its source restarting, and stops when an administrator revokes the key on Live Telemetry:

$ python3 rotorlab_relay_agent.py --url ws://127.0.0.1:8851/relay/agent --tcp 127.0.0.1:5761
17:51:42 tcp 127.0.0.1:5761
17:51:42 connecting to ws://127.0.0.1:8851/relay/agent
17:51:42 relay link up; sending telemetry (view-only)
17:53:00 error: [WinError 10054] An existing connection was forcibly closed by the remote host
17:53:00 reconnecting in 1s
17:53:01 tcp 127.0.0.1:5761
17:53:02 connecting to ws://127.0.0.1:8851/relay/agent
17:53:02 relay link up; sending telemetry (view-only)
18:03:19 relay closed the link (4003) device key revoked
18:03:19 this device key was revoked; create a new one on Live Telemetry

A second device, revoked the same way, showing the exit status that keeps the systemd unit from restarting it:

$ python3 rotorlab_relay_agent.py --url ws://127.0.0.1:8851/relay/agent --tcp 127.0.0.1:5761; echo "exit $?"
18:04:20 tcp 127.0.0.1:5761
18:04:20 connecting to ws://127.0.0.1:8851/relay/agent
18:04:20 relay link up; sending telemetry (view-only)
18:04:46 relay closed the link (4003) device key revoked
18:04:46 this device key was revoked; create a new one on Live Telemetry
exit 2

An agent started again with a revoked key is refused at sign-in and keeps retrying until you stop it:

$ python3 rotorlab_relay_agent.py --url ws://127.0.0.1:8851/relay/agent --tcp 127.0.0.1:5761
18:04:01 tcp 127.0.0.1:5761
18:04:01 connecting to ws://127.0.0.1:8851/relay/agent
18:04:02 error: relay refused upgrade: HTTP/1.1 401 Unauthorized
18:04:02 reconnecting in 1s
18:04:03 tcp 127.0.0.1:5761
18:04:03 connecting to ws://127.0.0.1:8851/relay/agent
18:04:03 error: relay refused upgrade: HTTP/1.1 401 Unauthorized
18:04:03 reconnecting in 2s

The checks it makes before it connects:

$ python3 rotorlab_relay_agent.py; echo "exit $?"
usage: rotorlab_relay_agent.py [-h] [--url URL] [--key KEY] [--udp UDP |
                               --tcp TCP | --serial SERIAL] [--baud BAUD]
                               [--insecure]
rotorlab_relay_agent.py: error: a relay device key is required: set ROTORLAB_DEVICE_KEY (or pass --key). Create one on Live Telemetry, under Cloud relay setup.
exit 2
$ ROTORLAB_DEVICE_KEY=rl_notadevicekey python3 rotorlab_relay_agent.py --url ws://192.0.2.10/relay/agent; echo "exit $?"
usage: rotorlab_relay_agent.py [-h] [--url URL] [--key KEY] [--udp UDP |
                               --tcp TCP | --serial SERIAL] [--baud BAUD]
                               [--insecure]
rotorlab_relay_agent.py: error: ws:// would send the device key unencrypted to 192.0.2.10. Use wss:// (the default is wss://app.rotorlab.app/relay/agent), or pass --insecure for a test network on purpose.
exit 2

Every message the agent prints, with what to do about it, is in docs/troubleshooting.md.

Run it as a service

examples/rotorlab-relay-agent.service is a hardened systemd unit. It runs the agent as an unprivileged dynamic user in the dialout group, reads the key from an environment file, limits its memory to 128 MB, and restarts it if it stops, except when it exits because the relay reported its key revoked.

sudo install -d -m 755 /opt/rotorlab-relay-agent
sudo install -m 644 rotorlab_relay_agent.py /opt/rotorlab-relay-agent/

# the key file, owned by root and readable by root only
# (systemd reads it before starting the agent)
sudo install -d -m 700 /etc/rotorlab
sudo install -m 600 -o root -g root /dev/null /etc/rotorlab/relay-agent.env
sudoedit /etc/rotorlab/relay-agent.env
# add the line: ROTORLAB_DEVICE_KEY=rlrd_...

sudo install -m 644 examples/rotorlab-relay-agent.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now rotorlab-relay-agent
journalctl -u rotorlab-relay-agent -f

Edit the ExecStart= line for your local side (--udp, --tcp or --serial) before you enable it. To rotate the key, create a new one in RotorLab, put it in /etc/rotorlab/relay-agent.env with sudoedit, run sudo systemctl restart rotorlab-relay-agent, then revoke the old one.

Upgrade and uninstall

Upgrade. Download the new rotorlab_relay_agent.py and SHA256SUMS.txt from the Releases page into one folder, verify the checksum, then replace the file and restart:

sha256sum -c SHA256SUMS.txt
sudo install -m 644 rotorlab_relay_agent.py /opt/rotorlab-relay-agent/
sudo systemctl restart rotorlab-relay-agent

The device key stays valid across upgrades. Read CHANGELOG.md first: each release says what changed.

Uninstall.

sudo systemctl disable --now rotorlab-relay-agent
sudo rm /etc/systemd/system/rotorlab-relay-agent.service
sudo systemctl daemon-reload
sudo rm -r /opt/rotorlab-relay-agent
sudo rm /etc/rotorlab/relay-agent.env
sudo rmdir /etc/rotorlab

Then revoke the aircraft's device key on Live Telemetry, under Cloud relay setup, so the key can never be used again. The agent writes no files of its own, so there is nothing else to remove.

Options

python3 rotorlab_relay_agent.py [--url URL] [--key KEY]
                                [--udp HOST:PORT | --tcp HOST:PORT | --serial DEV]
                                [--baud BAUD] [--insecure]
Option Default What it does
--url URL wss://app.rotorlab.app/relay/agent The relay endpoint. Must be ws:// or wss://, with no query string or fragment.
--key KEY the ROTORLAB_DEVICE_KEY environment variable The organization device key (rlrd_...). --key wins over the environment, but the environment keeps the key out of the process list.
--udp HOST:PORT 127.0.0.1:14550 Read a MAVLink UDP endpoint. Used when neither --tcp nor --serial is given.
--tcp HOST:PORT none Read a MAVLink TCP endpoint, for example 127.0.0.1:5760 for SITL. The port defaults to 5760 when left out.
--serial DEV none Read the flight controller's serial port, for example /dev/ttyAMA0. Linux and macOS.
--baud BAUD 115200 Serial speed. Any rate your system's termios supports (for example 57600, 115200, 921600).
--insecure off Testing only. Skips TLS certificate checks, and allows a plain ws:// address to a host other than this computer, which sends the device key unencrypted.
-h, --help Show the options and exit.

--udp, --tcp and --serial are mutually exclusive.

Exit status: 0 when stopped, 2 when the relay ends the link because the key was revoked. Command-line errors exit with 2 from the argument parser, with the reason printed.

Environment variable What it holds
ROTORLAB_DEVICE_KEY The organization device key. The recommended way to pass it.

Limits built into the agent: one message at most every 200 ms and at most 60 KB per message; at most 240 KB waiting to send before the oldest data is dropped; a frame from the relay larger than 64 KB ends the link.

Verify the download

Each release on this repository's Releases page includes rotorlab_relay_agent.py and a SHA256SUMS.txt file with its SHA-256 checksum. From v1.0.1, both files are also signed with the RotorLab release key: rotorlab_relay_agent.py.sig and SHA256SUMS.txt.sig. Check the signature first, then the checksum, before you run the file.

Check the signature

You need OpenSSH 8.2 or later (ssh-keygen ships with Linux, macOS and Windows 10 and 11). Save RotorLab's public release key as allowed_signers, in the same folder as the downloads:

echo 'release@rotorlab.app namespaces="rotorlab-release" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM9oNOu1L0o1g6JAyIUyeb2A9/pkRwLvuQeJmey01AeJ' > allowed_signers

Its fingerprint is SHA256:rp0unrj35IPjEQzYNrKCgpgglmBMwycOAAbxNRRG42s. Then:

ssh-keygen -Y verify -f allowed_signers -I release@rotorlab.app -n rotorlab-release -s SHA256SUMS.txt.sig < SHA256SUMS.txt
ssh-keygen -Y verify -f allowed_signers -I release@rotorlab.app -n rotorlab-release -s rotorlab_relay_agent.py.sig < rotorlab_relay_agent.py

Each command must print:

Good "rotorlab-release" signature for release@rotorlab.app with ED25519 key SHA256:rp0unrj35IPjEQzYNrKCgpgglmBMwycOAAbxNRRG42s

On Windows, run the same commands in Git Bash: PowerShell has no < redirect, and piping the file in can change its bytes. Anything other than Good means do not run the file.

Check the checksum

On Linux, with both files in the same folder:

sha256sum -c SHA256SUMS.txt

On macOS:

shasum -a 256 -c SHA256SUMS.txt

On Windows, in PowerShell:

Get-FileHash .\rotorlab_relay_agent.py -Algorithm SHA256

and compare the hash with the line in SHA256SUMS.txt. If they differ, do not run the file.

Tests and what this release was tested on

The tests need pytest and no RotorLab server. They load the agent by file path and, where a relay is needed, run a small WebSocket server on this computer. They also check that the file parses as Python 3.8 and imports only the standard library.

$ python -m pytest -q -p no:cacheprovider tests
..............................                                           [100%]
30 passed in 2.06s

For this release, on Windows 11 with Python 3.14:

  • the test suite passed, as above;
  • the agent streamed a synthetic SITL-style MAVLink stream over TCP to a local RotorLab server, and the Live Telemetry page showed it live in desktop and phone layouts (the screenshots on this page come from that run);
  • the agent reconnected after its source restarted, stopped with status 2 when its key was revoked, and was refused with HTTP 401 when started again with a revoked key.

UDP mode and serial mode were not run against a live source for this release; the tests cover their behavior on the local machine. docs/compatibility.md lists what has been run where.

Support

License

The RotorLab relay agent is licensed under the Apache License, Version 2.0. See LICENSE and NOTICE. It is provided without warranty of any kind.

RotorLab is a trademark of RotorLab, Inc. MAVLink, ArduPilot and PX4 are names of their respective projects and owners. Naming them here does not imply endorsement or affiliation.

About

RotorLab is a fleet operations platform for drone programs. It records flights, aircraft and people, and shows what the records say. The relay agent adds a live, view-only window onto an aircraft in flight. RotorLab does not authorize flights, and the agent does not control the aircraft.


RotorLab · Live Telemetry · Developers · Documentation · Support · Security · Apache 2.0
RotorLab, Inc., Dubuque, Iowa

About

View-only MAVLink telemetry relay for ArduPilot and PX4. One Python file, standard library, outbound WSS only.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages