Skip to main content

ROS 2 Humble Installation

GOAT Robotics

Introduction

ROS 2 (Robot Operating System 2) is an open-source framework that enables developers to build robotic applications with a modular and reusable architecture. It facilitates communication between different processes running on one or more robots, handling tasks such as sensor data processing, actuator control, and system management. Built on a publisher-subscriber model, ROS 2 allows decoupled components of the robotic system to communicate efficiently, promoting modularity and scalability.

The ROS 2 Humble Hawksbill release is the next long-term supported (LTS) version, designed to provide stability and continuity for robotic applications built on the ROS 2 platform. It is fully compatible with Ubuntu 22.04 (Jammy Jellyfish) and includes improvements in real-time capabilities, security features, and performance optimizations, making it ideal for industrial and large-scale robotic projects.

In this guide, we will walk you through the process of installing ROS 2 Humble on an Ubuntu 22.04 machine. By the end of the guide, you will have a fully functional ROS 2 setup that can be used to develop and deploy robotic applications.


Why ROS 2?

ROS 2 is an evolution of ROS 1, addressing several limitations of its predecessor. Key advantages of ROS 2 include:

  • Real-time performance: ROS 2 has improved real-time support, which is critical for time-sensitive robotic applications, particularly in industrial and automotive domains.
  • Multi-platform support: ROS 2 is cross-platform, meaning it can run not only on Ubuntu but also on Windows and macOS, broadening its accessibility for different development environments.
  • Security: Security enhancements in ROS 2 ensure that communication between nodes can be encrypted and authenticated, an essential feature for collaborative and cloud-based robotics.
  • Modular architecture: The modular design of ROS 2 allows for distributed processing across multiple robots or systems, facilitating the deployment of complex, multi-agent robotic applications.
  • DDS Middleware: ROS 2 uses the DDS (Data Distribution Service) protocol as its underlying communication middleware, which provides low-latency and high-throughput communication, making it suitable for both large-scale systems and safety-critical applications.

What You’ll Learn

By following this guide, you’ll learn how to:

  • Set up your Ubuntu 22.04 environment for ROS 2 Humble.
  • Install ROS 2 Humble and its necessary dependencies.
  • Set up and source your workspace for development.
  • Verify the installation by running example ROS 2 nodes.

This documentation will serve as a comprehensive resource for installing and configuring ROS 2 Humble on your system, as well as understanding the foundational components of a ROS 2-based robotic development environment.


1. System Requirements

Before proceeding with the installation of ROS 2 Humble on a Raspberry Pi 4B, ensure that your setup meets the following requirements:

  • Raspberry Pi Model: Raspberry Pi 4B (2GB RAM minimum, 4GB or 8GB recommended for improved performance)
  • Operating System: Ubuntu 22.04 (64-bit) or Ubuntu Server 22.04 (64-bit) for Raspberry Pi
  • Storage: MicroSD card with at least 32GB capacity (a faster card such as Class 10 is recommended)
  • Power Supply: 5V/3A USB-C power supply
  • Network: Stable internet connection (Ethernet recommended for faster downloads and setup)
  • Optional Peripherals:
    • Monitor (HDMI) for visual output
    • USB keyboard and mouse for input
    • Case and heatsink for better thermal performance

While 2GB of RAM is the minimum requirement, keep in mind that more demanding ROS 2 packages or large workloads might require more memory. For heavier applications, consider using a Raspberry Pi 4B with 4GB or 8GB of RAM.


2. Installing ROS 2 Humble on Ubuntu 22.04 for Raspberry Pi 4B

Now that your Raspberry Pi meets the system requirements, you can proceed with installing ROS 2 Humble Hawksbill. The installation process involves setting up your Raspberry Pi, adding the necessary repositories, and installing the ROS 2 Humble packages.

For detailed instructions, you can refer to the official ROS 2 Humble Installation Guide, which is continuously updated and provides step-by-step instructions for Ubuntu 22.04.


2.1 Prepare Your Raspberry Pi Environment

Before installing ROS 2 Humble, make sure your Raspberry Pi’s operating system is up to date. Run the following commands to update the package lists and upgrade all packages:

sudo apt update
sudo apt upgrade -y

ROS 2 Humble Installation on Ubuntu (deb packages)


Resources


Set locale

Make sure you have a locale which supports UTF-8. If you are in a minimal environment (such as a docker container), the locale may be something minimal like POSIX. The following steps show how to check and set the locale:

  1. Check for UTF-8 support:

    locale  # check for UTF-8
  2. Install locales:

    sudo apt update && sudo apt install locales
  3. Generate locale settings:

    sudo locale-gen en_US en_US.UTF-8
  4. Set the locale:

    sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    export LANG=en_US.UTF-8
  5. Verify locale settings:

    locale  # verify settings

Setup Sources

To install ROS 2 packages, you need to add the ROS 2 apt repository to your system.

  1. Ensure that the Ubuntu Universe repository is enabled:

    sudo apt install software-properties-common
    sudo add-apt-repository universe
  2. Add the ROS 2 GPG key:

    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
  3. Add the ROS 2 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

  1. Update your apt repository caches:

    sudo apt update
  2. Upgrade the system before installing ROS 2:

    sudo apt upgrade
  3. Install ROS 2 packages:

    • Desktop Install (Recommended): ROS, RViz, demos, and tutorials.

      sudo apt install ros-humble-desktop
    • ROS-Base Install (Bare Bones): Communication libraries, message packages, and command line tools. No GUI tools.

      sudo apt install ros-humble-ros-base
    • Development Tools: Compilers and other tools to build ROS packages.

      sudo apt install ros-dev-tools

Environment setup

After installing ROS 2, you will need to set up your environment to use ROS 2 commands in your terminal sessions.

Sourcing the setup script

Each time you open a new terminal, you must source the ROS 2 environment to set up your environment properly.

  1. Source the setup script:

    # Replace ".bash" with your shell if you're not using bash
    # Possible values: setup.bash, setup.sh, setup.zsh
    source /opt/ros/humble/setup.bash
  2. Automatically source ROS environment: To ensure ROS 2 is automatically sourced when opening a new terminal, add this to your .bashrc:

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

Try some examples

After setting up ROS 2, try running a simple example to ensure everything works correctly.

Talker-listener

  1. Run the talker: Open a new terminal, source ROS 2, and run the talker node:

    ros2 run demo_nodes_cpp talker
  2. Run the listener: Open another terminal, source ROS 2, and run the listener node:

    ros2 run demo_nodes_cpp listener

You should see the listener node receiving messages from the talker.


Next steps after installing

After installing ROS 2, you can explore more advanced usage and development options.

Using the ROS 1 bridge

If you're migrating from ROS 1 or need to integrate ROS 1 packages, you can use the ROS 1 bridge to enable communication between ROS 1 and ROS 2 nodes.

Refer to the ROS 1 bridge documentation for installation instructions and usage.

Additional RMW implementations (optional)

ROS 2 supports multiple RMW (ROS Middleware) implementations. You can install and experiment with these for different performance characteristics. Some available implementations include FastDDS, CycloneDDS, and others.

Refer to the RMW documentation for more details.


Troubleshooting

If you encounter issues during installation or while using ROS 2, refer to the ROS 2 Troubleshooting Guide for tips and common solutions.


Uninstall

To remove ROS 2 from your system, run the following commands:

  1. Remove ROS 2 packages:

    sudo apt remove ros-humble-*
  2. Remove all dependencies installed with ROS 2:

    sudo apt autoremove

For a complete removal, you may also delete configuration and log files associated with ROS 2.