ROS2 on i.MX8 M Mini NavQ for Mobile Robotics (*DRAFT)

Showing results for 
Search instead for 
Did you mean: 

ROS2 on i.MX8 M Mini NavQ for Mobile Robotics (*DRAFT)

NXP Employee
NXP Employee
NavQ is described on Gitbook -

***DRAFT*** This is a work in progress and may have errors.
This page holds suggestions for general settings of navq.
**** NOTE your hardware configuration may differ from the instructions here. Please post a reply where you find issues and we'll update.
**** These instructions are for a setup that includes MAVLINK over an  Ethernet Connection between the NavQ and the RDDRONEFMUK66. Unfortunately you will not have the RJ45 to 2-wire ethernet adapter that is needed. Modifications will be needed to make this work with UART based communications

[Credits - Gerald Peklar, Peter Van Der Perk]
Documentation below assumes internet access of navq via wifi. Guide on how to enable wifi is available on navq gitbook -
The editor nano is helpful. Install nano with (internet access required).
~$ sudo apt install nano
Since several NavQs might be present in a Wifi Network it's desired to set an unique hostname to determine the "right" navq to connect to.
Modify /etc/hostname with a unique host name. Proposal is to use
navq-[Vehicle Mavlink SysID]
e.g. if Mavlink SysID is 10 the navq should be named navq-10
~$ sudo nano /etc/hostname
Setting a fixed IP to use eth for FMU communication

Since there is no DHCP on a drone and FMUK66 has a fixed IP of we need to set a fixed IP for eth0 to be able to communicate via ethernet to FMUK66.
Suggestion is to use for navq. is reserved for the D2X gen1 board acting as a network switch.
connman is used for setting the network . To force connman to use a fixed IP in case of no DHCP is available the following file needs to be created.
~$ sudo nano /var/lib/connman/ethernet.config
Name = Ethernet_config
Description = Ethernet fixed IP setting

Type = ethernet
IPv4 =
The IP4 settings are ownIP/netmask/router. is set assuming a D2X board is in place.
Setting up FMUK66 for mavlink over T1 ethernet

T1 ethernet is supported by PX4 on FMUK66 with latest master.
To enable FMUK66 sending mavlink telemetry via UDP to a specific IP is done by setting up the following file on the FMUK66 SDcard.
mavlink start -x -u 14551 -o 14551 -r 200000 -t -m onboard is the IP address of navq on the vehicle.
Description of the mavlink start parameters on
Additionally the MAV_BROADCAST parameter on the FMU needs to be set to 2 - only multicast.
Setting up mavlink_router
(The first section is general setup/configuration)
(The second section is about installing ROS2 on the NavQ itself)

To be able to have several end nodes communicating via mavlink we need to set up mavlink-router on the navq.
End nodes can be 
  • a process for onboard control running on navq.
  • a QGC computer the navq connects to via wifi.
  • other mavlink enabled peripherals on the vehicle.
Compile and installation of mavlink router is done with the following steps on the navq (internet access required):
~$ mkdir src
~$ cd src
~/src$ git clone
~/src$ cd mavlink-router 
~/src/mavlink-router$ git submodule update --init --recursive
~/src/mavlink-router$ ./ && ./configure CFLAGS='-g -O2' --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --prefix=/usr
~/src/mavlink-router$ make
~/src/mavlink-router$ sudo make install
Configuration of mavlink router is done via a single configuration file expected as /etc/mavlink-router/main.conf
This file needs to be created from scratch. Example configuration file -
Setup the config file with minimal configuration
~$ sudo nano /etc/mavlink-router/main.conf
#Mavlink router configuration navq

[UartEndpoint FMUuart]

[UdpEndpoint FMUeth]
Mode = Eavesdropping
Address =
Port = 14551

[UdpEndpoint QGConMobile]
Mode = Normal
Address =
Port = 14550
The configuration above assumes that the navq gets mavlink data from FMU either via UART3 (/dev/ttymxc2) or UDP.
You can leave out the unused connection.
Via the UdpEndpoint QGConMobile section the mavlink stream is forwarded to a QGC computer/mobile device assuming it has and navq is connected to this network via e.g. wifi.
Enable the autostart of mavlink-router via systemd and start it
~$ sudo systemctl enable mavlink-router
~$ sudo systemctl start mavlink-router
Finally you can check the status of mavlink router via
~$ sudo systemctl status mavlink-router
Locale environment settings

Good source for how-to do locale setting is
Example settings for Germany
First generate the German locales
sudo locale-gen de_DE.UTF-8
Set the German locales but have messages in english still. This is defined by LC_MESSAGES setting.
sudo update-locale LANG=de_DE.UTF-8
sudo update-locale LC_MESSAGES=POSIX
Setting up FMUK66 for fastRTPS

  1. Update PX4 build environment to latest status and build the code with
    make nxp_fmuk66-v3_rtps
  2. upload the generated nxp_fmuk66-v3_rtps FW into FMUK66.
  3. Prepare the FMU's SD card by adjusting /etc/extras.txt file.
    This will autostart the fastRTPS communication at boot time.
    Add the following line in to /etc/extras.txt

    micrortps_client start -t UDP -i


Assuming that NavQ is running with IP

Setting up ROS2 on NavQ

All commands to be executed on NavQ
  Install ROS2 foxy using

Follow the guide on

Note (1): at Setup Sources step you might get an error message by curl

To avoid this do upfront

sudo rm -rf /usr/lib/libcurl*
sudo apt install curl

Note (2): at Install ROS2 package step use

sudo apt install ros-foxy-ros-base


Desktop is not needed on a headless system!
System requirements
~$ sudo apt update
~$ sudo apt install cmake python3-pip gradle python3-colcon-common-extensions gradle
~$ pip3 install --user pyros-genmsg


Setting up PX4 Ros com for ROS2 Foxy

 If you have no src directory yet on NavQ's home directory just create it 

~$ mkdir src
~$ cd src 
~/src$ git clone --recursive -b 1.8.x FastRTPS-1.8.2
~/src$ cd FastRTPS-1.8.2
~/src/FastRTPS-1.8.2$ mkdir build
~/src/FastRTPS-1.8.2$ cd build 
~/src/FastRTPS-1.8.2/build$ cmake -DTHIRDPARTY=ON -DSECURITY=ON .. 
~/src/FastRTPS-1.8.2/build$ make 
~/src/FastRTPS-1.8.2/build$ sudo make install


cd ~/src
~/src$ git clone --recursive -b v1.0.4 Fast-RTPS-Gen
~/src$ cd Fast-RTPS-Gen
~/src/Fast-RTPS-Gen$ unset TERM
~/src/Fast-RTPS-Gen$ ./gradlew assemble
~/src/Fast-RTPS-Gen$ sudo su
~/src/Fast-RTPS-Gen# unset TERM
~/src/Fast-RTPS-Gen# ./gradlew install
~/src/Fast-RTPS-Gen# exit


cd ~/
mkdir -p ~/px4_ros_com_ros2/src
git clone ~/px4_ros_com_ros2/src/px4_ros_com
git clone ~/px4_ros_com_ros2/src/px4_msgs


# Note building px4_ros_com requires a lot of ram, enable a swap disk is recommended
Execute building PX4 ROS2
~$ ./px4_ros_com_ros2/src/px4_ros_com/scripts/build_ros2_workspace.bash


 Starting MicroRTPS bridge  Prerequisit - Ethernet configuration



See also Setting a fixed IP to use eth for FMU communication in Wiki and Setting up FMUK66 for mavlink over T1 ethernet in Wiki

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

~$ micrortps_agent -t UDP -i

see  Setting up FMUK66 for fastRTPS in Wiki


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

sudo apt install ros-foxy-rqt-topic

rqt_topic --force-discover
Autostart micrortps client via systemd on NavQ

The instruction below assumes that you have successfully executed Setting up ROS2 on NavQ in Wiki
Generate a start up script for the micrortps client under /usr/local/bin
sudo nano /usr/local/bin/
with content
## startup script for micro_rtps_agent
## agent will communicate to FMUK66 via UDP
## FMUK66 IPv4 addr = 
## Author: Gerald Peklar <>  
source /opt/ros/foxy/setup.bash
source ~/px4_ros_com_ros2/install/setup.bash
micrortps_agent -t UDP -i
Save the file and exit nano.
Make the file executable
sudo chmod +x /usr/local/bin/
Generate a systemd service file to start the startup script at boot
sudo nano /etc/systemd/system/micrortps_agent.service
with content
Description=PX4 micrortps service


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
0 Kudos
0 Replies