5
Installation

5.1 ROS 2 Humble Hawksbill

5.1.1 Introduction

This section is written and edited for students who wish to install ROS on their own computers which has Linux 1 1 Of course, it is assumed the student has Ubuntu 22.04 installed. If any other system is installed such as Arch, or NixOs, then I would like to use the following text printed out when a user uninstalls their boot-loader from their computer: “Bailing out, you are on your own. Good Luck.” on it. For student who will use Docker containers, you can skip this chapter.

Before we tackle the wonderful world of robot programming, we must first install all the essential tools we need to make sure it works. Below are the instructions on how to do it.

Please read the instructions first and then apply the commands as required by the instructions. This is not just a one-time warning and should be carefully noted as Linux while powerful can be unforgiving if one does NOT take good care and attention to what they type to the terminal.

5.1.2 Setting up the Local

Make sure you have a locale which supports UTF-8. 2 2 A character encoding standard used for electronic communication. Defined by the Unicode Standard , the name is derived from Unicode Transformation Format - 8-bit. Almost every web page is stored in UTF-8. If you are in a minimal environment (such as a docker container), the locale may be something minimal like Portable Operating System Interface (POSIX) . We test with the following settings. However, it should be fine if you’re using a different UTF-8 supported locale.

To start with installation, if you are using a GUI open up your terminal ( Ctrl + Alt + T ).

bash
locale # check for UTF-8 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 locale # verify settings

Information : The POSIX Standard

POSIX is a set of standard OS interfaces based on the Unix operating system. The most recent POSIX specifications IEEE Std 1003.1-2024 defines a standard interface and environment that can be used by an OS to provide access to POSIX -compliant applications. The standard also defines a command interpreter 3 3 such as the shell. and common utility programs. POSIX supports application portability at the source code level so applications can be built to run on any POSIX -compliant OS .

5.1.3 Setting Up the Source Files

Before we can begin working with ROS , we must install all the necessary files and dependencies required. For these lectures we will install ROS Humble Hawksbill which is currently available for Ubuntu Jammy (22.04 LTS).

While currently there are more up-to-date version of ROS available such as Jammy, due to its long term support and established compatibility, we will be using ROS Humble.

It is heavily recommended to be on Ubuntu 22.04 LTS as ROS Humble is only officially supported on this version. It is possible to compile ROS on other Ubuntu or Linux distributions, however, you need to compile the binaries yourself.

We will need to add the ROS apt repository to your system.

Information : The Advanced Package Manager

A free-software user interface that works with core libraries to handle the installation and removal of software on Debian and Debian-based Linux distributions. It is just another package manager.

First ensure that the Ubuntu Universe 4 4 A snapshot of the free, open-source, and Linux world. It houses almost every piece of open-source software, all built from a range of public sources repository is enabled.

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

Now add the ROS GPG key with apt.

Information : GPG

A hybrid-encryption software which uses a combination of conventional symmetric-key cryptography for speed, and public-key cryptography for ease of secure key exchange, typically by using the recipient’s public key to encrypt a session key which is used only once.

bash
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

Then add the repository to your sources list . This list contains all the paths your system will scan when it is looking for a package or to look for updates.

bash
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

Information : The echo Command

A command that outputs the strings that are passed to it as arguments. It is a useful command to let the user know what process is going on with the current running program or allows the insertion of text to other files.

5.1.4 Install ROS 2 Packages

Update your apt repository caches after setting up the repositories as it may NOT have the latest version on it. The ROS packages are built on frequently updated Ubuntu systems.

It is always recommended that you ensure your system is up to date before installing new packages.

bash
sudo apt update && sudo apt upgrade

Once updated you have a few options on which type to install ( 1 st is recommended)

Desktop Install

It install all the necessary components and software packages such as ROS , RViz, demos, tutorials.

bash
sudo apt install ros-humble-desktop
Development tools

Compilers and other tools to build ROS packages.

bash
sudo apt install ros-dev-tools

This setup may take some time as the file download size is around 2GB.

5.1.5 Setting Up the Environment

Once the software is installed we still need to tell our shell where the software is so we can call it in our session. For this we need to source a script. Set up your environment by sourcing the following file in your terminal ( Ctrl + Alt + T ).

bash
source /opt/ros/humble/setup.bash

Alternatively, if you prefer to automate this action, simply type the following code in your terminal:

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

The aforementioned command simply writes the command to the last line of a document called .bashrc which is a script that runs whenever you open a new terminal window.

The .bashrc file is a script file that’s executed when a user logs in. The file itself contains a series of configurations for the terminal session. This includes setting up or enabling: colouring, completion, shell history, command aliases, and more.

It is a hidden file and simple ls command won’t show the file.

5.2 Auto-Install Script

As a bonus, if you have read the document before doing copy and pasting, you can use the rosinstall.sh provided to you to automatically install everything required for this course.

bash
#!/bin/bash # First check your Ubuntu Version # For maximum compatability with ROS it needs to be 22.04 LTS # Creating log for troubleshooting echo "###### BEGIN ATTEMPT #######" »install_log.txt echo "Welcome to ROS 2 Automated Installation" echo "" echo "" # Accessing the Ubuntu version using AWK and piping it to grep for Regex version=$( awk "/VERSION_ID/" IGNORECASE=1 /etc/*release | grep -Eo "[[:digit:]]+([.][[:digit:]]+)?" ) # Checks version for ROS Compliance if [[ "${version}" == *"22.04"* ]]; then echo "Version is supported." sleep 1 echo "Continuing installation..." sleep 1 else echo "Your version: "$version", What is needed: 22.04" echo "I am sorry but your version is not supported." echo "This install script will terminate" exit fi echo "" echo "Installing UTF-8 Compliance ..." { locale # check for UTF-8 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 locale # verify settings } &»install_log.txt echo "" echo "Enabling Ubuntu Universe Repositories..." { sudo apt install software-properties-common echo | sudo add-apt-repository universe } &»install_log.txt echo "" echo "Adding ROS 2 GPG Keys ..." { 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 } &»install_log.txt echo "" echo "Adding ROS 2 to repository ..." { 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_log.txt echo "" echo "Getting Updates ..." { sudo apt update echo yes | sudo apt upgrade } &»install_log.txt echo "" echo "Installing ROS ..." { echo yes | sudo apt install ros-humble-desktop yes | sudo apt install ros-dev-tools } &»install_log.txt { sudo apt install dbus-x11 } &»install_log.txt echo "" echo "Sourcing ROS file ..." sleep 1 echo "source /opt/ros/humble/setup.bash" »~/.bashrc echo "" echo "Removing unnecessary files ..." sleep 1 { yes | sudo apt autoremove } &»install_log.txt