Setting Up a ROS 2 Humble Development Environment on Ubuntu 22.04

Last update: 05-13-2024

Welcome to this tutorial on setting up your development environment for ROS 2 Humble on Ubuntu 22.04. This guide will take you through a step-by-step process, ensuring you have everything you need to start working with ROS 2.

1. Prerequisites

Before we begin, make sure that your system is running Ubuntu 22.04 and has Python3 installed. These are essential components to successfully install and run ROS 2.

2. Install ROS 2 Humble

To install ROS 2 Humble, you can either follow the detailed instructions provided in the official ROS documentation or execute the following commands in your terminal to prepare and install the necessary packages:

sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

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

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

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

sudo apt update
sudo apt install ros-humble-desktop -y

3. Install Colcon

Colcon is a command line tool to improve the workflow of building, testing, and using multiple software packages. It is particularly tailored for bundles of software that utilize interdependencies. To install colcon, simply run the following command:

sudo apt install python3-colcon-common-extensions -y

4. Configuring the Environment

Lastly, to ensure ROS 2 and colcon are readily available in your terminal sessions, you need to add them to your system's path. Open your .bashrc file with nano by using:

nano ~/.bashrc

Then, append the following lines to the end of the file to source the setup scripts:

source /opt/ros/humble/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

Save and exit the editor. For these changes to take effect, you can restart your terminal or source the .bashrc file directly with
source ~/.bashrc

5. Verifying Installation

After installation, it's important to verify that both ROS 2 and colcon are correctly installed. Run the following command to check ROS 2:

ros2 doctor

This should output "All 5 checks passed," indicating that your ROS 2 environment is properly configured.

Next, test colcon by running:

colcon test

You should see a popup indicating "colcon test successful," and the terminal should show "Summary: 0 packages finished," confirming that colcon is ready for use.

You're now ready to begin your journey with ROS 2 Humble on Ubuntu 22.04!

0 Comments

Add a new comment: