Companion Computer
This section introduces how to set up the (on-board) companion computer for PX4-based drones.
Hardware Connection
FTDI Devices / Logic Level Shifters
Connect onboard computer and Pixhawk flight controller via an FTDI Chip USB-to-serial adapter.
use the
TELEM2
port on Pixhawk and a USB port on companion computermake sure the FTDI chip or logic level shifter is compatible in our use case
see this section for recommended ones (Pixdev discontinued though)
make sure the pin-to-pin connection is correct
out of 6 pins, 3 pins must be connected (TX-RX, RX-TX, GND-GND)
the red power pin must not be connected
CTS and RTS pins are optional; for the use of so called "flow control" for Pixhawk
see this section for the full wiring table
It is recommended that the FTDI chip operates at 3.3V, but not required
the red power pin is not connected anyway
according to this section in PX4 docs, all Pixhawk serial ports operate at 3.3V and are 5V level compatible.
Example: USB FTDI Serial to JST-GH (Basic)
warning: this product is not a ready-to-go adapter; need to switch RX and TX cables (cut them off and then solder together)
see this video for a quick recap about soldering two wires together
soldering quality can also affect the performance; bad soldering will lead to high noise level in the communication
the connection link is: computer --- USB port --- USB to micro USB cable --- micro USB port --- FTDI chip --- 6-pin JST port --- JST cable --- 6-pin TELEM2 port --- Pixhawk
WiFi Router
Need to prepare a high-speed low-latency WiFi router
edit settings to shrink DHCP range and leave a range of IP addresses unused for static IP
in my case, I use
192.168.0.21
for onboard computer and192.168.0.121
for gcs computer
PX4 Firmware
Need to enable MAVLink on a configurable serial port (typically
TELEM2
).Connect the Pixhawk flight controller to QGroundControl via USB or Telemetry (TELEM1), so that you can change parameters in the parameter table and push them to the vehicle.
Set param MAV_1_CONFIG =
TELEM 2
(MAV_1_CONFIG is often used to map the TELEM 2 port)Reboot the vehicle to make other parameters visible.
Set the remaining parameters if not being set by default.
MAV_1_MODE =
Onboard
SER_TEL2_BAUD =
921600
(921600 or higher recommended for applications like log streaming or FastRTPS)
Once this parameter is enabled, when Pixhawk is powered on, it will automatically broadcast messages (drone status) via TELEM2 port. The RX indicator should be flickering accordingly.
Onboard Computer
Set up a static IP address for WiFi connection
in my case, I use
192.168.0.21
for onboard computer and192.168.0.121
for gcs computeroptional: edit
hosts
file bysudo gedit /etc/hosts
and add item192.168.0.121 arcs-gcs
udev rule: create a new file at
/etc/udev/rules.d/99-pixhawk.rules
with the following contentdouble check by
lsusb
the actual vendor and product ID of the FTDI chip
Add current user to the
tty
anddialout
groups to avoid to have to execute scripts as root
Launch file is the same as
mavros/launch/px4.launch
except for the following modificationsset
fcu_url
to/dev/ttyPixhawk:921600
set
gcs_url
toudp://@arcs-gcs:14550
double check if
tgt_system
matchesMAV_SYS_ID
parameter in PX4 firmware (default 1)double check if
tgt_component
matchesMAV_COMP_ID
parameter in PX4 firmware (default 1)
Ground Control Station (GSC) Computer
Set up a static IP address for WiFi connection
in my case, I use
192.168.0.21
for onboard computer and192.168.0.121
for gcs computeroptional: edit
hosts
file bysudo gedit /etc/hosts
and add item192.168.0.21 arcs-robot
optional: set up password-free SSH login by
ssh-copy-id arcs@arcs-robot
Download QGroundControl Ubuntu amd64 build (arm architecture is not supported)
run
./QGroundControl
and you can see drone statusit will automatically listen to port 14550 for UDP connections
Troubleshooting
Hardware connection
lsusb
check the vendor ID and product ID of FTDI chipls -l /dev/ttyPixhawk
check the read/write permissionuse a multi-meter to check voltage level
find a chip that has TX/RX indicators to help debugging
mavros connection
rostopic echo -n1 /diagnostics
rosrun mavros checkid
Issue: FCU not connected
If TELEM2 port is indeed broadcasting messages, then
cat /dev/ttyPixhawk
should print out random symbols/streaming androstopic echo -n1 /diagnostics
should have RX packages/bytes received.See this issue in mavros repository for more details.
References
PX4 docs: Companion Computer Peripherals
PX4 docs: Companion Computer for Pixhawk Series
PX4 docs: MAVLink Peripherals (GCS/OSD/Companion)
PX4 docs: Serial Port Configuration
Holybro docs: Pixhawk 4 Pinout Manual
Examples for Healthy/Successful Connections
roslaunch mavros px4.launch
rostopic echo -n1 /diagnostics
rosrun mavros checkid
Last updated