Setting up ROS 2 Humble Hawksbill on Ubuntu

Environment

Ubuntu 22.04

Setup Sources

Enable the Ubuntu Universe repository.

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

Add the ROS 2 GPG key with apt.

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

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

WARNING: ROS2 tools like colcon does not quite work with conda environments, so it's recommended to install ROS-related things directly under system environment. In this case, make sure when running the commands, the conda environment is disabled:

> (base)$ conda deactivate
> $

apt will install things to system directory, but pip will install it to current active Python directory.

Update apt repository caches after setting up the repositories, and ensure the system is up to date before installing new packages.

sudo apt update
sudo apt upgrade

Install Desktop Install, including ROS, RViz, demos, and tutorials.

sudo apt install ros-humble-desktop

Install Colcon

Colcon is a tool used to build ROS 2 software packages.

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

Adding Environment Variables

~/.bashrc
# ROS 2 Humble
source /opt/ros/humble/setup.sh

Colcon also has a tool, colcon_cd, to help navigating to package directories.

~/.bashrc
# ROS 2 Humble
...
source /usr/share/colcon_cd/function/colcon_cd.sh

Additional Tools

sudo apt install python3-rosdep2
rosdep update

other possible required dependencies

sudo apt install ros-humble-joint-state-publisher-gui
sudo apt install ros-humble-xacro

With Ubuntu 22.04 + ROS 2 Humble combination, we also need the following dependencies for building turtlesim:

pip install empy
pip install lark

Install Gazebo support

sudo apt install ros-humble-gazebo-ros2-control ros-humble-gazebo-ros

Last updated