Repository navigation
PX4 Offboard Control
Last updated: Nov 7, 2019
Insert figure

Note: This has been tested on Ubuntu 18.0.3 LTS.
For basic Quadrotor usage
cd ~/src/Firmware
make px4_sitl gazeboTip:
px4_sitlandpx4_sitl_defaultare equivalent
Usemake px4_sitl list_vmd_make_targets | grep gazebo_to get a list of available gazebo simulation cases.
Once started the vehicle can be monitored and controlled using GCS such as QGroundControl with joystick configured.
Refer to point 2 in References to understand how PX4 make works.
References:
According to PX4, Offboard Control is used in context of companion computer. In this document, Offboard Control is used for command and control from GCS applications such as ROS.
Install MAVROS
Install MAVROS as a part of the PX4 toolchain with ROS setup or for manual install on a ROS enabled system, follow the instructions in point 2 in References.
Usage:
- test all the cases belowFor example, when autopilot is connected via USB at 57600 baud, GCS running on localhost:
rosrun mavros mavros_node _fcu_url:=/dev/ttyUSB0:57600 _gcs_url:=udp://<fill in here>Tip: Add additional GCS connections using
_gcs_url=
GCS Bridge Additional Proxy
Allows you to add a channel for GCS. For example if you need to connect one GCS for HIL and the second on the tablet. Example (SITL & QGroundControl):
rosrun mavros mavros_node _gcs_url:='udp://:14556@172.16.254.129:14551' &
rosrun mavros gcs_bridge _gcs_url:='udp://@172.16.254.129'Install MAVProxy
For Debian based systems:
sudo apt-get install python3-dev python3-opencv python3-wxgtk3.0 python3-pip python3-matplotlib python3-pygame python3-lxml python3-yaml
sudo pip install MAVProxyTip: If you encounter python version issue (likely, when ROS Melodic is installed), try point 2 in References. ROS Melodic uses Python2, therefore default Python is Python2.
For Windows based systems:
A complete windows installer for MAVProxy is available at http://firmware.ardupilot.org/Tools/MAVProxy/.
Usage: Offboard Control of PX4 running on hardware
When PX4 is running on the hardware (e.g. Pixhawk series board) and connected to the GCS computer via SiK Telemetry Radio, then it's the serial port (e.g. /dev/ttyUSB*) can be routed to two more ports 14550 and 14590 (Any port number can be chosen except 14540, 14570, 14580). The two new ports can be assigned to QGroundControl (uncheck auto connect UDP and configure UDP connection under Comm Links) and other offboard control application such as MATLAB or ROS.
mavproxy.py --master=/dev/ttyUSB0,57600 --out=udp:127.0.0.1:14550 --out=udp:127.0.0.1:14590 --dialect=commonTip: Default dialect for MAVProxy is
ardupilotmega. Change it tocommonif using PX4.
Tip: For splitting SiK Telemetry for multiple QGC instances, use port UDP
14550for auto-connection.
Creating Windows Shortcut
Tip: For Windows, replace
mavproxy.pywithmavproxyand/dev/ttyUSB*with respectiveCOM*port.
In the desired folder, open Right-click menu -> New -> Shortcut and in the location enter:
C:\Windows\System32\cmd.exe /k cd C:\"Program Files (x86)"\MAVProxy && "mavproxy.exe" --master=com4,57600 --out=udp:127.0.0.1:14550 --out=udp:192.168.43.1:14550 --dialect=common --non-interactive
Note: Although MAVProxy worked, it has known to cause issues in Mission Mode, when used with two instances of QGC such as laptop application and mobile app. It is likely due to MAVProxy using MAVLink v1 instead of v2.
Usage: Offboard Control of PX4 Simulation
Note: This has been tested on Ubuntu 18.04.3 LTS running ROS Melodic and Gazebo 9.
Similarly, when PX4 is running on the host computer in SITL, then it's remote port 14550 can be routed to two more ports such as 14590 and 14595.
mavproxy.py --master=udp:127.0.0.1:14550 --out=udp:127.0.0.1:14590 --out=udp:127.0.0.1:14595 --dialect=commonIf QGC is being run on a remote client such as phone/tablet (with IP 192.168.0.102), then an external port such as 14550 on that IP can be set. For example,
mavproxy.py --master=udp:127.0.0.1:14550 --out=udp:192.168.0.102:14550 --out=udp:127.0.0.1:14595 --dialect=commonAny other combination of QGC port and Offboard control application port can be chosen based on their host machine.
References:
MAVLink Router was developed by Intel for Intel Aero RTF Drone to route MAVLink messages from the FC on UART to internal Intel Aero Board (companion computer) and external QGC (GCS).
Install MAVLink Router
In the desired directory, first clone the repo, then build and install.
git clone https://github.com/intel/mavlink-router
git submodule update --init --recursive
./autogen.sh && ./configure CFLAGS='-g -O2' --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib64 --prefix=/usr
make
make installTip: If ROS Melodic is installed, it uses Python2 as default python compiler. As of Nov 2019, MAVLink Router has been ported Python2 to Python3. So overcome any installation errors, try
apt install python3-futureorpip install python3-future. As far as author understands,python-futureis used to run Python2 to Python3 ported code on Python3 compiler.
Usage
When routing from SiK Telemetry module to local UDP port
mavlink-routerd -e 127.0.0.1:14550 /dev/ttyUSB0:57600Usage: Offboard Control of PX4 running on hardware
When routing from SiK Telemetry module to local UDP port (QGC laptop application) and an external UDP port (OGC mobile app). This is particularly helpful in the field - the QGC on mobile serves as dashboard for the pilot and QGC on the laptop serves as dashboard for the observers.
mavlink-routerd -e 127.0.0.1:14550 -e 198.168.43.1:14550 /dev/ttyUSB0:57600Usage: Offboard Control of PX4 Simulation
When offboard API or an external command and control is running on the host computer same as PX4 SITL and QGC is running externally.
mavlink-routerd -e 127.0.0.1:14590 -e 198.168.43.1:14550 127.0.0.1:14550References: