Skip to content

Installing ROS 2 Humble

Guilherme Burkert edited this page Feb 14, 2025 · 2 revisions

ROS 2 Humble Initial Setup

*Warning: This tutorial uses Ubuntu Linux 22.04

First ensure that you have both software-properties-common and the Ubuntu Universe repository installed:

sudo apt install software-properties-common
sudo add-apt-repository universe

Next, add the ROS 2 GPG key with apt:

sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

Afterward, add the repository to your sources list:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

Install ROS 2 packages

Before continuing, update your apt repository cache after setting up the repositories and make sure (it is extremely recommended) that your system is fully upgraded:

sudo apt update
sudo apt upgrade

Then, install ROS2 Humble packages:

sudo apt install ros-humble-desktop

Typically, it is always needed to source the ROS environment when opening a ROS terminal:

source /opt/ros/humble/setup.bash

To save time, it is possible to automate this process so that every time you open a new shell, it happens automatically, like this:

echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc

Testing

To test if the API is working correctly, run the C++ talker example in one terminal:

ros2 run demo_nodes_cpp talker

And in another window, run the Python listener example:

ros2 run demo_nodes_py listener

If everything is working, the expected behavior is:

image image

Creating a Workspace

*First, make sure that the environment has been initialized using the source command before starting

Create a fbot_ws directory (to indicate that this is the fbot workspace) and a src folder where the repositories will be stored:

mkdir -p ~fbot_ws/src
cd ~/fbot_ws/src

Clone the desired repositories into the /fbot_ws/src directory:

git clone https://github.com/butia-bots/fbot_description.git
git clone https://github.com/butia-bots/fbot_navigation.git

*Other repositories from the team can be found by clicking here

For private repositories (like fbot_behavior), do the same, but you will need to use your GitHub username with access to it and a personal access token (or an SSH key) as a password.

git clone https://github.com/butia-bots/fbot_behavior.git

*For more information on how to create a personal access token, click here

The authorization will look like this:

image

Where YOUR_USERNAME should be your email that is part of the organization, and the password field should be filled with the personal access token.

Go back to the root repository /fbot_ws to continue:

cd ..

After that, initialize rosdep:

sudo rosdep init
rosdep update

Then, resolve the dependencies for the repositories in /fbot_ws:

rosdep install -i --from-path src --rosdistro humble -y

Build the workspace:

colcon build

After that, in a new terminal, use the source:

source /opt/ros/humble/setup.bash

Then, go to the root of the directory and create a local overlay source:

cd ~/fbot_ws
source install/local_setup.bash

*To better understand how different types of sources (overlay/underlay) work, click here

More information

If more information is needed, you can consult the ROS documentation at:

Installation

Creating a Workspace

Or continue Installing Gazebo to run simulations at:

Installing Gazebo