Robotic Operating System, abbreviated as ROS, is a free and open source software that provides a collection of tools and libraries needed for building robot applications. It provides everything you need for your robotics project, from powerful developer tools, and state-of-the-art algorithms to a comprehensive set of drivers.
Although you can install ROS from the source, the easiest approach to install ROS on Ubuntu jammy is to install the corresponding Debian packages using the APT package manager.
In this guide, we learn how to install ROS 2 humble on Ubuntu 22.04.
To get started, here is what you need.
- An instance of Ubuntu 22.04 desktop.
- A sudo user configured on your instance.
Step 1: Set locale
The first step is to check if your system supports UTF-8. To do so, run the following command on the terminal.
If you get the following command output, you are all set and good to go.
If your system does not support UTF-8, then install locales by running the command:
sudo apt update && sudo apt install locales
Once installed, generate the UTF-8 locale using the following commands.
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
Then define and export the environment variable.
At this point, your system should provide support for the UTF-8 locale. You can verify that UTF-8 is now supported using the locale command.
Step 2: Add Official ROS 2 Humble repository to Ubuntu
The next step is to add the official ROS2 Humble repository to your system. To accomplish this, some essential packages are required. Proceed and install them as follows.
sudo apt install software-properties-common curl gnupg lsb-release
Installing ROS 2 Humble requires you to enable the Ubuntu Universe repository to your system. The Universe repository is a standard repository that provides free and opensource software that is community-maintained.
So, to add the Universe repository to your system, run the command:
sudo add-apt-repository universe
Once the repository is added, update the package lists as follows.
sudo apt update
Next, add the public GPG key provided by ROS.
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
Once the GPG key is added, add the ROS 2 repository to the /etc/apt/sources.list.d/ directory using the following command.
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
Step 3: Update the ROS 2 package index
After setting up the ROS repository, update the APT repository cache.
sudo apt update
Be sure to also upgrade all the packages to their latest versions.
sudo apt upgrade
Step 4: Install ROS 2 Humble on Ubuntu 22.04
Once the system packages are up to date, install ROS humble desktop package using the APT package manager. This installs a host of components inlcuding core ROS libraries, developer tools, Python libraries, and other dependencies. The ros-humble-desktop package is quite big ( over 2 GB ), hence, ensure that you have a stable internet connection. and sufficient disk space.
sudo apt install ros-humble-desktop
If you are using ROS for the first time, we strongly recommend the desktop install. On the other hand, you can opt to install the minimal setup or the essentials ( without the helpful GUIs or learning materials that come with the desktop install) using the command:
sudo apt install ros-humble-ros-base
sudo apt install ros-humble-ros-core
Step 5: Set up ROS 2 Humble environment
Once the installation is complete, you need to source the setup file. To do this, run the following commands.
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc source ~/.bashrc
If you are on zsh shell, run the commands:
echo "source /opt/ros/humble/setup.zsh" >> ~/.zshrc source ~/.zshrc
Step 6: Verify ROS 2 installation
To test if the ROS APIs are working properly, navigate to the /opt/ros/humble/lib/demo_nodes_cpp/ directory.
Then run the C++ talker as follows.
ros2 run demo_nodes_cpp talker
If everything is working properly, you will get the following output
Alternatively, switch to the /opt/ros/humble/lib/demo_nodes_py/ directory.
And run the Python listener to check if the python apis are working using the following command.
ros2 run demo_nodes_py listener
You should get the following output.
The output generated in these examples is sure proof that your ROS 2 humble installation is working as expected.
In this tutorial, we learned how to install ROS 2 humble on Ubuntu 22.04.
Thanks for reading, please leave your feedback and suggestions in the below comment section.