Forwarding MAVLink packets
Forwarding MAVLink Packets Using MAVProxy and MAVLink Router
MAVLink (Micro Air Vehicle Link) is a lightweight communication protocol used in various unmanned systems, including drones. It enables communication between different components like ground control stations (GCS), autopilots, and onboard computers. For some setups, there’s a need to forward MAVLink packets across multiple networks or interfaces to achieve smooth communication between these components. One of the most effective ways to accomplish this is by using tools like MAVLink Router and MAVProxy.
In this blog post, we’ll explain how to forward MAVLink packets using MAVLink Router and MAVProxy, provide configuration examples, and guide you through typical use cases.
Why Forward MAVLink Packets?
Forwarding MAVLink packets is necessary when you want to:
Send telemetry data from a drone to multiple ground control stations (GCS).
Relay MAVLink data across different communication mediums (e.g., serial, UDP, TCP).
Enhance the scalability of your system by allowing multiple devices to communicate with the same autopilot.
Debug and monitor MAVLink messages without disturbing the primary connection.
What is MAVLink Router?
MAVLink Router is a tool designed to route MAVLink messages between different communication interfaces. It supports multiple endpoints (UDP, TCP, and serial connections), which makes it a great option for forwarding MAVLink packets between devices. MAVLink Router is efficient and lightweight, making it ideal for embedded systems like companion computers running on drones.
Installing MAVLink Router
First, you need to install MAVLink Router on your system. For Linux-based systems (like Ubuntu), you can follow these steps:
Once installed, you can begin forwarding MAVLink packets.
Example: Forwarding MAVLink Packets with MAVLink Router
Let’s consider an example where you want to forward MAVLink packets from a serial device (like /dev/ttyUSB0
on your drone) to multiple ground stations using UDP.
You can achieve this with MAVLink Router using the following command:
Explanation of the command:
/dev/ttyUSB0:115200
: The serial device and baud rate of the MAVLink telemetry from the drone’s flight controller.--endpoint 192.168.1.100:14550
: This is the IP address and port of the first ground station where you want to forward MAVLink packets.--endpoint 192.168.1.101:14550
: The second ground station.
This setup will read MAVLink data from /dev/ttyUSB0
and forward it to both ground stations (192.168.1.100 and 192.168.1.101).
Configuration Using a .conf File
You can also use a configuration file to define endpoints and interfaces in a more organized manner.
Create a config file, mavlink-router.conf
, with the following content:
Then, run MAVLink Router with the config file:
What is MAVProxy?
MAVProxy is another powerful MAVLink ground control station and development tool. It can act as a proxy to forward packets between interfaces, allowing you to monitor and manipulate MAVLink messages. MAVProxy is often used for testing, debugging, and creating custom GCS applications.
Example: Forwarding MAVLink Packets with MAVProxy
In a scenario where you have a telemetry link over a serial connection, you can use MAVProxy to forward data to a UDP endpoint.
First, install MAVProxy:
To start forwarding MAVLink packets from a serial device (/dev/ttyUSB0
) to a UDP port (192.168.1.100:14550
), run the following command:
Explanation of the command:
--master=/dev/ttyUSB0
: The serial device connected to the drone.--out=udp:192.168.1.100:14550
: The IP address and port of the ground station where the packets will be forwarded.
Additional MAVProxy Commands
MAVProxy allows you to add multiple outputs if you need to forward data to several endpoints. For example:
You can also view MAVLink messages in real-time using MAVProxy:
The --console
option opens a real-time console to visualize incoming MAVLink messages.
Hopefully, this guide helps you set up MAVLink packet forwarding in your own projects. Happy flying!
References:
Last updated