Using mavlink-router to route MAVLink streams over the network

Jaeyoung Lim

MAVLink is a standard protocol which is used for drones both for internal communications and external communications. It is a popular interface for flight controllers such as PX4, Ardupilot, Betaflight and more. This was mainly used for GCS such as Qgroundcontrol, Mission Planner for the command control link. However, this is also useful for handling onboard communication outside the flight controller, where many components talk to the flight controller.

mavlink-router is a intel opensource project that routes mavlink streams to specific endpoints. This was first implemented on the Intel Aero, to handle communications with the companion computer.

In addition to routing streams, mavlink-router have exciting features that can be very useful and improve your workflow.

This can be done either manually, or configuring a configuration file. To run manually, endpoints can be defined with a -e flag.

mavlink-routerd -e 192.168.7.1:14550 -e 127.0.0.1:14550 /dev/ttyS1:1500000

To run the mavlink-router from a configuration file, it can be done with the -c flag.

mavlink-routerd -c /mavlink.conf

where the following is a sample of the configuration file.

[General]
#Mavlink-router serves on this TCP port
TcpServerPort=5790
ReportStats=false
MavlinkDialect=auto
Log=$HOME/log/flight-stack
LogMode=while_armed

[UdpEndpoint alfa]
Mode = Eavesdropping
Address = 0.0.0.0
Port = 10000

[UartEndpoint bravo]
Device = /dev/ttyUSB0
Baud = 52000

[UdpEndpoint charlie]
Mode = Normal
Address = <ADDRESS>
Port = 11000

[TcpEndpoint delta]
Address = 127.0.0.1
Port = 25790
RetryTimeout=10

The configuration of each endpoint can be done as the example. Each endpoint has a type and a name.

[ ]

We will go through each configurations.

Routing mavlink streams from the drone

mavlink-router routes the mavlink-stream between endpoints. The normal usage of mavlink-router is to listen to a flight controller(either a serial port or a UDP port) and forward this message to other endpoints (TCP port / UDP port).

[UartEndpoint bravo]
Device = /dev/ttyUSB0
Baud = 52000

A UartEndpoint is defined to listen to a serial device. This is usually the flight controller. The mavlink stream can be routed to a UdpEndpoint or a TcpEndpoint to a specified address and port.

[UdpEndpoint charlie]
Mode = Normal
Address = <ADDRESS>
Port = 11000

[TcpEndpoint delta]
Address = 127.0.0.1
Port = 25790
RetryTimeout=10

In order to forward the mavlink stream to your GCS / server, you can specify the mode as Mode = Normal. You can still send commands to the FCU from the UdpEndpoint/TcpEndpoint.

Broadcasting mavlinks over a network

You can also broadcast mavlinks over the entire network. This can be done by broadcasting over the Bcast address of the network. This is useful if you are using a VPN and have a dedicated network for controlling the drone.

[UdpEndpoint charlie]
Mode = Normal
Address = <ADDRESS>
Port = 11000

Offboard Logging

mavlink-router provides logging functions in which enables logging on the companion computer. No more pulling out the SD card from the flight controller for the logs!

Log=$HOME/log/flight-stack
LogMode=while_armed

Logging is simply enabled by adding the Log directory in the configuration file. You can also specify the LogMode in order to set the behavior of the logging. if log mode is set as LogMode=whlie_armed the log file is created only once the flight controller is armed and marks the file as read-only.

Note: The current mavlink-router implementation only enables logging functions when the `sys_id=1

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s