6. Install and setup mavlink-router


What is mavlink-router?

Whether the flight controller communicates with the Raspberry Pi or the Raspberry Pi communicates with the ground station, they are all through mavlink.

When the Raspberry Pi receives the mavlink data from the flight controller via the serial port, the mavlink-router will distribute the mavlink data to other devices. (e.g. ground station, simulator or your computer visual program, etc.)

Install mavlink-router

Login to your raspberry pi, then:

If you didn’t install git, you may install it

sudo apt update
sudo apt install git

Download the source

git clone https://github.com/intel/mavlink-router.git
cd mavlink-router
git submodule update --init --recursive

Config it

./autogen.sh && ./configure CFLAGS='-g -O2' \
--sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib64 \

In my case, there are some warning echo but still works


make install

If show ImportError: No module named 'future' when make
Install it by pip3 install future
If no pip3
Install it by sudo apt-get install python3-pip\

Create a config file

sudo mkdir /etc/mavlink-router
sudo pico main.conf

My config is:

[UartEndpoint rpi]
# Device = /dev/ttyAMA0
# Device = /dev/ttyS0
Device = /dev/serial0
Baud = 57600

It tells mavlink-router where is the serial port of the mavlink input. In my case, it is /dev/serial0

Please find the sample of config file here.

###Run The command below will read the mavlink data then forward it to the port 14550 and localhost port 14550.

mavlink-routerd -e -e

Connect the Ground Station

For example, your ground station is on, above mavlink-router command can let it receives the mavlink data from UDP port 14550. The QGroundControl will listen the UDP port 14550 by default, no need to config it. It is a sample below:

Auto start mavlink-router when system boot

Create the file below to /etc/mavlink-router.service

Description=MAVLink Router
After=network-online.target zerotier-one.service

ExecStart=/usr/bin/mavlink-routerd -e {groundstation}:14550


Replace the {groundstation} to the IP of your ground station

Testing the service

sudo systemctl start mavlink-router.service

Enable the service

If the testing runs fine, we can enable the service.

sudo systemctl enable mavlink-router.service

Check the status

If you find the mavlink-router didn’t start up, you can check the status:

systemctl status mavlink-router.service

Welcome your comments