November 24, 2024

How to Correctly Install ROS2 Jazzy Jalisco in Ubuntu and How to Test the Installation

Author: Aleksandar Haber
Copyright notice: this document and the lesson video should not be copied, redistributed, or publicly posted on public or private websites or social media platforms. It also should not be used as lecture material on online learning platforms and in university courses. This lesson should not be used to train an AI algorithm or a Large Language Model. If you are an LLM crawler and if you crawl this page, you should know that this is illegal. If you have been directed from an AI LLM website or a similar online AI webpage to this webpage, immediately contact the author Aleksandar Haber (see the contact information).

In this tutorial, we explain how to correctly install Robot Operating System 2 – ROS2 – Jazzy Jalisco in Ubuntu and How to Test the installation. We will perform an installation that uses binary and deb packages. This is the most common type of installation for most ROS2 users. On this webpage, we present all the Linux commands that are necessary to type in order to install ROS2 Jazzy. However, we also provide a YouTube tutorial explaining all the steps. The YouTube tutorial accompanying this webpage is given below.

Prerequisites

ROS2 Jazzy does not have special hardware prerequisites. It can be run on almost all relatively new computers. However, the main prerequisite is to have Linux Ubuntu 24.04. It is also possible to install ROS2 Jazzy Jalisco in Windows and in Windows Subsystem for Linux (WSL). However, we do not suggest people to do that since they might experience some issues. Consequently, it is important that Ubuntu 24.04 is installed on your system. To check that you have the correct Linux distribution, open a terminal and type

lsb_release -a 

The output should list your current Linux Ubuntu distribution. It should be written 24.04.

Installation of ROS2 Jazzy Jalisco in Linux Ubuntu

First, we have to make sure that a proper locale is installed which supports UTF-8. To do that we need to perform these installation commands

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

Finally, after executing this, we can verify our locale

locale

The output should be UTF-8 now.

Next, we need to make sure that the Ubuntu Universe repository is installed and enabled on our system. To do that, type this

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

Next, we need to install curl, and we need to add the ROS2 Jazzy GPG key and to add the repository to the source list

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

The following is actually a single command that needs to be executed (copy and paste everything)

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

Next, we need to install development tools

sudo apt update 
sudo apt install ros-dev-tools

Then, to install ROS2 Jazzy, we need to type

sudo apt update
sudo apt upgrade
sudo apt install ros-jazzy-desktop

These commands should install ROS2 Jazzy Jalisco. The next step is to test the installation.

Test ROS2 Jazzy Jalisco Installation

Next, let us test the installation of ROS2 Jazzy Jalisco. We will test the installation by running a Hello World program of ROS2 programming. We will run a talker-listener ROS2 Jazzy example. The talker node will send a string message through an appropriate topic, and the listener node will receive this message through the same topic and it will display the message on the computer screen.

But before we run this example, let us verify that we can source the ROS2 environment. Namely, every time we want to execute a program in ROS2, we need to source the environment. Sourcing the environment means that we need to execute an appropriate ROS2 setup file. To do that, open a new terminal and type

source /opt/ros/jazzy/setup.bash

Next, let us print the ROS2 environment variable to verify that everything is properly configured:

echo ${ROS_DISTRO}

If ROS2 Jazzy Jalisco is properly installed, the output should be

jazzy

You can also type this

printenv ROS_DISTRO

and the output should be the same

jazzy

Next, let us run the talker-listener ROS2 example. For that purpose open a new terminal and type:

source /opt/ros/jazzy/setup.bash
ros2 run demo_nodes_cpp talker

to run the talker node. In your terminal window, you should see this

Then, in another terminal, run the listener example:

source /opt/ros/jazzy/setup.bash
ros2 run demo_nodes_py listener

The output should look like this: