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
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.
To start with installation, if you are using a GUI open up your terminal ( Ctrl + Alt + T ).
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
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
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.
Then add the repository to your
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.
Once updated you have a few options on which type to install ( is recommended)
- Desktop Install
-
It install all the necessary components and software packages such as ROS , RViz, demos, tutorials.
- Development tools
-
Compilers and other tools to build ROS packages.
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
Alternatively, if you prefer to automate this action, simply type the following code in your terminal:
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.
#!/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