Installing ROS 2 Humble on Ubuntu
This tutorial will focus on installing Humble Hawksbill, the latest LTS release for ROS 2, on Ubuntu Jammy.
Though it’s possible to install ROS 2 from source or archive, the easiest way to get ROS running on your Ubuntu machine is to install its corresponding Debian packages using
apt, a command line utility for installing and managing packages on Linux distributions.
In this tutorial, we’ll walk you through installing the Debian packages for ROS 2 Humble Hawksbill on Ubuntu Jammy (22.04 LTS).
Set up a UTF-8 system locale
Before installing anything, you’ll need to make sure your system locale supports UTF-8. Locale issues can cause unexpected problems further down the line, when using various ROS tools and libraries.
$ locale in a terminal window to view your currently installed locale – if UTF-8 appears in the listed output, you’re all set!
Otherwise, you'll need to set up your locale in one of two ways – choose a locale on your system or generate a new one.
Show more info.
Set up your source repos
Ubuntu programs are stored in repositories that make installing new software easy and secure. Ubuntu’s four main repositories are as follows:
- Main (Canonical-supported open-source software)
- Universe (community-maintained open source software)
- Restricted (proprietary device drivers)
- Multiverse (proprietary software)
For the purposes of installing ROS, we need to enable the Ubuntu Universe repository:
$ sudo apt install software-properties-common $ sudo add-apt-repository universe
Now you can add the ROS 2 repository to your system. Authorize the public GPG (GNU Privacy Guard) key provided by ROS, then add the ROS 2 repository to your sources list:
$ sudo apt update && sudo apt install curl gnupg lsb-release $ 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 $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
Install ROS 2 packages
Install your ROS 2 Humble desktop setup with the following commands:
$ sudo apt update # update your apt repo caches $ sudo apt install ros-humble-desktop
This will install a few different components like the core ROS libraries, developer tools like RViz, and a set of beginner-friendly tutorials and demos to help you get started.
Show more info.
Source your setup file
Typically, you would need to source your setup file every time you open a terminal to use ROS:
$ source /opt/ros/humble/setup.bash
To save yourself the time, you can automatically trigger this step every time you launch a new shell. Run the following commands if you’re using a
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc source ~/.bashrc
Run the following commands if you’re using a
echo "source /opt/ros/humble/setup.zsh" >> ~/.zshrc source ~/.zshrc
Run some examples
After completing the desktop install, let’s make sure that our APIs are working properly.
**Run the example C++ talker **at
$ ros2 run demo_nodes_cpp talker
The output should confirm that the talker is successfully publishing messages:
[INFO] [1652382860.246687611] [talker]: Publishing: 'Hello World: 1' [INFO] [1652382861.250208871] [talker]: Publishing: 'Hello World: 2' [INFO] [1652382862.246508551] [talker]: Publishing: 'Hello World: 3' ...
In another terminal window, **run the example Python listener **at
$ ros2 run demo_nodes_py listener
The output should confirm that the listener is hearing the published messages:
[INFO] [1652382936.495044030] [listener]: I heard: [Hello World: 1] [INFO] [1652382937.478216343] [listener]: I heard: [Hello World: 2] [INFO] [1652382938.487370309] [listener]: I heard: [Hello World: 3] ...
Both the C++ and Python APIs are working properly!
NOTE: If you’re experiencing issues here, make sure that you’ve enabled multicast – the network interface needs this in order to communicate via DDS.
Run the following commands in two separate terminal windows:
$ ros2 multicast receive $ ros2 multicast send
If the first command does not return a successful output (i.e.
Received from xx.xxx.xxx.xx:43751: 'Hello World!'), try updating your firewall configuration:
$ sudo ufw allow in proto udp to 188.8.131.52/4 $ sudo ufw allow in proto udp from 184.108.40.206/4
Then, restart your terminal and try starting up your talker and listener again.
To uninstall ROS 2, remove the repository from your system completely:
$ sudo apt remove ~nros-humble-desktop && sudo apt autoremove $ sudo rm /etc/apt/sources.list.d/ros2.list $ sudo apt update $ sudo apt autoremove $ sudo apt upgrade # for previously shadowed packages
Visualize and analyze your data with Foxglove
Once you’ve gotten the lay of the land and started recording your robots’ data, you’ll need to start visualizing your data to understand what’s going on under the hood of your robots.
This would be a good time to check out the specs for the MCAP file format. Not only are MCAP files smaller (and more performant!) than standard ROS 2 files, they’re also completely self-contained (unlike ROS 2 files that draw from message definitions living on your hard drive), making it possible for you to share these files with teammates for them to visualize. By adhering to a common container format, the MCAP file format encourages interoperability among third-party developer tools like Foxglove Studio and Foxglove Data Platform.
Foxglove provides a convenient
mcap CLI tool to help you convert your ROS 2 (.db3) files into MCAP (.mcap) files. These files can then be imported directly into Foxglove Data Platform, so your whole team can collaborate on organizing and tagging your data:
They can also be dragged-and-dropped into Foxglove Studio for instant rich visualizations. Load up your data to view camera images, display 3D markers, review log messages, and more:
Join the Foxglove Slack community to ask questions and learn more.
- ROS 2 Humble docs and tutorials
- Ubuntu repositories
- ROS 2 distribution variants
- MCAP file format
- Foxglove Studio docs
- Foxglove Data Platform docs
Automate building re-usable base images for your hobby robots.
Write messages in the JSON or Protobuf format for easy visualization in Foxglove Studio.
Get blog posts sent directly to your inbox.