Compiling Cartographer ROS

System Requirements

The Cartographer ROS requirements are the same as the ones from Cartographer.

The following ROS distributions are currently supported:

  • Melodic
  • Noetic

Building & Installation

In order to build Cartographer ROS, we recommend using wstool and rosdep. For faster builds, we also recommend using Ninja.

On Ubuntu Focal with ROS Noetic use these commands to install the above tools:

sudo apt-get update
sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow

On older distributions:

sudo apt-get update
sudo apt-get install -y python-wstool python-rosdep ninja-build stow

After the tools are installed, create a new cartographer_ros workspace in ‘catkin_ws’.

mkdir catkin_ws
cd catkin_ws
wstool init src
wstool merge -t src https://raw.githubusercontent.com/cartographer-project/cartographer_ros/master/cartographer_ros.rosinstall
wstool update -t src

Now you need to install cartographer_ros’ dependencies. First, we use rosdep to install the required packages. The command ‘sudo rosdep init’ will print an error if you have already executed it since installing ROS. This error can be ignored.

sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y

Cartographer uses the abseil-cpp library that needs to be manually installed using this script:

src/cartographer/scripts/install_abseil.sh

Due to conflicting versions you might need to uninstall the ROS abseil-cpp using

sudo apt-get remove ros-${ROS_DISTRO}-abseil-cpp

Build and install.

catkin_make_isolated --install --use-ninja

This builds Cartographer from the latest HEAD of the master branch. If you want a specific version, you need to change the version in the cartographer_ros.rosinstall.