Building from Source
This guide will help you build the CPM Lab ROS2 project from source. This is especially useful for development and customization.
Note
This guide is for developers who want to build the project from source. If you are not developing features, consider using the Install from Debian Packages instead.
Dependency Overview
π§ Ubuntu 24.04 β ROS2 Jazzy (supported)
π§ Ubuntu 22.04 β ROS2 Humble (simulation only)
π§ Ubuntu 26.04 β ROS2 Lyrical (in preparation)
π» IDE: Recommended β Visual Studio Code
π An SSH key in your RWTH GitLab account: the repositories are cloned via SSH only
See Supported Platforms for what each distribution supports. Replace <ros2-distro> in the commands below with
your distribution, e.g. jazzy.
Installation Steps
Follow these steps to set up your development environment from source:
1. Install ROS2
Follow the official installation instructions for your system:
Attention
You must install ROS development tools:
sudo apt update && sudo apt install ros-dev-tools
For Ubuntu 26.04 following packages must be installed and rosdep must be initialized:
sudo apt install ros-lyrical-desktop ros-dev-tools ros-lyrical-rmw-zenoh-cpp
sudo rosdep init
rosdep update
2. Set Up Visual Studio Code (Recommended)
We suggest using Visual Studio Code for a smoother development experience:
π₯ Download VS Code
π¦ Install the following extensions:
ROS
C/C++
Open the Extensions view (Ctrl + Shift + X), search for these, and click Install.
3. Clone the Repository
Clone the CPM Lab workspace with all submodules. The repositories are only available via SSH: add an SSH key to your account first (GitLab β Preferences β SSH Keys, see the GitLab documentation). Checking out via HTTP(S) is not supported.
git clone git@git.rwth-aachen.de:CPM/Project/Lab/ros2/workspaces/ros2-workspace-lab.git --recursive
Your workspace path is now: <path-to-ros2-workspace>
4. Install Dependencies
Make sure your ROS2 environment is sourced:
cd <path-to-ros2-workspace>
source /opt/ros/<ros2-distro>/setup.bash
make dependencies
For Ubuntu 26.04:
Build Lanelet2 and mrt_cmake_modules from source.
mkdir -p ~/dev/lanelet2_ws/src && cd ~/dev/lanelet2_ws/src
git clone https://github.com/KIT-MRT/mrt_cmake_modules.git
git clone https://github.com/fzi-forschungszentrum-informatik/Lanelet2.git
# Boost 1.89+ (Ubuntu 26.04 ships 1.90) no longer has a separate boost_system library
sed -i 's/ wave system chrono / wave chrono /' mrt_cmake_modules/yaml/cmake.yaml
cd ~/dev/lanelet2_ws
source /opt/ros/lyrical/setup.bash
# CMake 4 rejects cmake_minimum_required() below 3.5 in mrt_cmake_modules
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
--packages-skip lanelet2_examples lanelet2_validation lanelet2
cd <path-to-ros2-workspace>
source /opt/ros/<ros2-distro>/setup.bash
source ~/dev/lanelet2_ws/install/setup.bash
make dependencies
5. Install the Middleware
The real lab needs Eclipse Zenoh; for simulations on your own computer, CycloneDDS works as well. See Middleware for the differences.
sudo apt install ros-<ros2-distro>-rmw-zenoh-cpp
echo "export RMW_IMPLEMENTATION=rmw_zenoh_cpp" >> ~/.bashrc
With Zenoh, start the router in a separate terminal before the lab (ros2 run rmw_zenoh_cpp rmw_zenohd); in the
real lab it runs on the central workstation.
6. Build the Project
Once dependencies are in place:
cd <path-to-ros2-workspace>
source /opt/ros/<ros2-distro>/setup.bash
make build
π§Ή To clean the workspace (optional):
make clean
7. Open in Visual Studio Code
Start VS Code from your workspace:
cd <path-to-ros2-workspace>
code .
π‘ Use Ctrl + Shift + B to run the build task inside VS Code; Tasks: Run Test Task runs the tests, see
Testing and CI.
8. Launch the CPM Lab
π₯οΈ Launch the control flow together with RViz and the Control Center:
cd <path-to-ros2-workspace>
source install/setup.bash
export ROS_DOMAIN_ID=21
ros2 launch cpm_lab cpm_lab_rviz.launch.xml
Note
On computers without the Basler pylon library, build with make simulation instead of make build. This skips
the indoor positioning system, which is only needed in the lab.
See Running the Lab for the other launch files and Command Reference for all daily commands.
Developing in Docker
Instead of installing ROS2 and the dependencies on your computer, you can build and run the workspace in Docker,
either from the terminal with make targets or in the VS Code dev container. Both use the images of
docker/Dockerfile and the container settings of compose.yaml in the workspace:
Image |
Used by |
Contains |
|---|---|---|
|
Zenoh router, control center, rqt |
ROS2 Jazzy core, RViz, rqt, Zenoh and CycloneDDS, the Foxglove bridge, the run dependencies of the packages, the Basler pylon SDK, acados 0.5.5 and CasADi 3.7.2 |
|
Builds, terminals, VS Code dev container |
The runtime image plus compilers, colcon, the build and test dependencies, gdb, git and passwordless |
The workspace is mounted at /workspace and built in the container, and ~/cpm_lab is mounted for experiments,
calibrations and your own maps and IPS configurations. The containers run as a user with your user and group ID, so build/, install/ and log/
belong to you. They use the host network, Zenoh with a router container, ROS_DOMAIN_ID=21 (override it with
ROS_DOMAIN_ID=<id> make ...), X11 for RViz and rqt, and the USB devices for the IPS camera. acados and CasADi
have the same versions as on the muCars, see muCar.
Requirements: Docker with the Compose plugin and make on a Linux host with X11 for the GUI tools.
From the terminal, run in the workspace root:
make control-center # Zenoh router, build if anything changed, control center with RViz
make control-center-foxglove # the same with the Foxglove bridge instead of RViz
make terminal # shell with ROS and the workspace sourced, e.g. for make build
make down # stop and remove all containers
See Command Reference for all targets.
In VS Code, install the Dev Containers extension, open the workspace folder and run Dev Containers: Reopen in Container. VS Code builds the image, starts the dev container and the Zenoh router, and builds the workspace. ROS and the workspace are sourced in every terminal.
To add a dependency, declare it in the package.xml of the package that needs it: the images install the
dependencies with rosdep. Other system packages go into docker/Dockerfile. The next make target or Rebuild
Container in VS Code rebuilds the images.
π Youβre Done! π
Your development environment is now set up. You can start building new features, testing simulations, or contributing to the CPM Lab ecosystem.
If you run into issues, refer to our Troubleshooting Guide or see Getting Help and FAQ.