Auto-start microRTPS client/agent on FMU/NavQ

Creating a systemd service to auto-start the microRTPS agent on NavQ

Generate a start up script for the micrortps client under /usr/local/bin

sudo nano /usr/local/bin/start_micrortps_agent.sh

with content

#!/bin/bash
## startup script for micro_rtps_agent
## agent will communicate to FMUK66 via UDP
## FMUK66 IPv4 addr = 10.0.0.2 
##
## Author: Gerald Peklar <gerald.peklar@nxp.com>  

source /opt/ros/foxy/setup.bash
source ~/px4_ros_com_ros2/install/setup.bash

# Comment out the line that you are not using:

# If you're using T1 Ethernet communication:
micrortps_agent -t UDP -i 10.0.0.2

# If you're using UART communication over the UART3 port:
micrortps_agent -d /dev/ttymxc2 -b 921600

Save the file and exit nano. Make the file executable

sudo chmod +x /usr/local/bin/start_micrortps_agent.sh

Generate a systemd service file to start the startup script at boot

sudo nano /etc/systemd/system/micrortps_agent.service

with content

[Unit]
Description=PX4 micrortps service
After=network.target

[Service]
Restart=always
TimeoutStartSec=10
User=navq
Group=navq
WorkingDirectory=~
ExecStart=/usr/local/bin/start_micrortps_agent.sh

[Install]
WantedBy=multi-user.target

Save the file and exit nano. Check if the process starts

sudo systemctl start micrortps_agent.service
sudo systemctl status micrortps_agent.service

You should see an state active (running), quit with <q> Enable the systemd service file finally to be active at boot

sudo systemctl enable micrortps_agent.service

Auto-start the microRTPS client on the FMU

To run fastRTPS over Ethernet with NavQ board the RDDRONE-T1ADAPT is needed.

Building PX4 with microRTPS

You will need a Linux VM or computer to complete this step.

In order to use the microRTPS client on NavQ, you'll need to build PX4 with the _rtps tag for the fmuk66-v3 build target. To do this, you will need to have both the FastRTPS and Fast-RTPS-Gen packages installed. You can just follow the previous guide on your Linux development VM or computer.

Once you have successfully installed those two packages, you can navigate to your cloned PX4 repository and run the following:

$ make nxp_fmuk66-v3_rtps

Flashing your FMU with the updated binary

You will need to flash your FMU with the updated RTPS binary. If you don't know how to do this yet, follow the guide here:

Creating a startup file on the SD card

To make the microRTPS client start at boot on the FMU, you will need to have an SD card inserted. On your SD card, make a file at /etc/extras.txt and insert one of the following options:

set +e
# For T1 Ethernet communication:
micrortps_client start -t UDP -i <NavQ_IP_Address>

# For UART communication over the TELEM port:
micrortps_client start -d /dev/ttyS4 -b 921600

# For UART communication over the IR/TELM2 port:
micrortps_client start -d /dev/ttyS1 -b 921600
set -e

Calling set +e at beginning / set -e at end is needed to prevent from boot errors. Further details can be found on https://dev.px4.io/master/en/concept/system_startup.html#replacing-the-system-startup

Last updated