Building a Docker Image for ROS2 & QNX Development

Docker is a tool that can be used to easily create environments that are reproducible and lightweight. In this tutorial we will use it to set up a development environment for building ROS2 for QNX.

Requirements

  • Docker-CE

    • Can be setup on Ubuntu using Docker’s official convenience script:

curl https://get.docker.com | sh && sudo systemctl --now enable docker

Steps

1- Clone the Dockerfile.

git clone https://gitlab.com/qnx/frameworks/ros2/docker

2- Prepare the docker build context with the QNX SDP. If the SDP is located in your home directory, run the following.

rsync -havz ~/qnx710 ./docker/

We use rsync -havz rather than a regular cp to preserve the symbolic links inside the SDP. If this is not done, the size of the copied SDP will be significantly larger.

3- Build the docker image with the included script.

cd docker
./docker-build-qnxros2-image.sh galactic

4- Run the image with the included script to create a container. This will open an interactive terminal into the Docker container.

./docker-create-container.sh galactic

5- Inside of the container’s interactive terminal, set the CPU environment variable to the target cpu architecture for the build of ROS2. For example:

export CPU=x86_64
# or
export CPU=aarch64
# or
unset CPU # Build for all supported architectures

6- Perform the rest of the operations displayed by the welcome message to build ROS2.

. ./env/bin/activate
cd ros2_galactic
./build-ros2.sh