December 22, 2024

How to Properly Install MoveIt2 in ROS2 Humble and Fix Tutorial Errors

In this ROS2 tutorial, we explain how to properly install MoveIt 2 in ROS2 Humble and how to start with robot visualization in RViz and motion planning. We also explain how to fix errors that occur when one is trying to load robot models from the official MoveIt tutorial package. The YouTube video accompanying this post is given below.

Important Notes

Before starting with the installation process, you need to understand the following.

  • Before you start with an installation process, it is very important to make sure that your Linux version is Ubuntu 22.04 and that the ROS2 version is Humble.
  • We will not blindly follow the installation tutorial posted on MoveIt2 website. This is mainly because of the fact that the tutorial provided online will NOT completely work (this video is made in July 2024, maybe after this they will fix the official tutorial). Instead, we explain how to perform several fixes, that will enable you to smoothly install MoveIt and run an example of an industrial robot in RViz. In the future, we will also create another tutorial, once the official maintainer of MoveIt2 applies fixes to the issues with the tutorials. Also, in the future, there will be a version of MoveIt2 for the newest version of ROS2 Jazzy Jalisco, and we will create MoveIt2 tutorials for Jazzy Jalisco.
  • The process of installing MoveIt2 might take 20-30 minutes of build time. Consequently, you have to be patient and you have to follow all the steps and instructions. Otherwise, you will not be able to install MoveIt2

Installation

This installation is based on the official MoveIt 2 tutorial page. However, as mentioned previously, we will have to make several modification to fix the errors. First, check the Linux version. Open a terminal, and type

lsb_release -a

This should give Linux Ubuntu 22.04. Next, we need to verify that we have the correct ROS2 version. We do that by typing:

cd /opt/ros
ls -la

You should see “humble” folder. Then, let us double check by typing:

source /opt/ros/humble/setup.bash
printenv ROS_DISTRO

This should give “humble” as an output. Let us start with installation. Open a new terminal, and type

source /opt/ros/humble/setup.bash

Next, we need to execute the following set of commands to install rosdep and upgrade:

sudo apt install python3-rosdep
sudo rosdep init
rosdep update
sudo apt update
sudo apt dist-upgrade

Next, we need to install Colcon build system with mixin, and vcstool:

sudo apt install python3-colcon-common-extensions
sudo apt install python3-colcon-mixin
colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
colcon mixin update default
sudo apt install python3-vcstool

Next, we need to create the workspace and source folder, clone the tutorials for the Humble branch (this is the main difference with respect to the official installation page)

mkdir -p ~/ws_moveit/src
cd ~/ws_moveit/src
git clone --branch humble https://github.com/ros-planning/moveit2_tutorials
vcs import < moveit2_tutorials/moveit2_tutorials.repos

Here, the main difference with respect the official installation page is the option “–branch humble” when cloning the tutorials.

Next, we need to build everything. We do that by typing:

sudo apt update && rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y
cd ~/ws_moveit
colcon build --mixin release --executor sequential

Here, the main difference with respect to the official installation page is that we have added an option “–executor sequential” to the colcon build command. This will make sure that the installation does not use the complete computer CPU resources. Without this option, the installation will be stuck.

Also, the colcon build command will take around 20-30 minutes to complete. After completing this, you can source MoveIt 2 like this:

source ~/ws_moveit/install/setup.bash

Note that whenever you want to use Moveit 2, you need to execute this command.