Installation Guide

This tutorial will briefly introduce the basic tools you are going to use throughout this course and how to install them. The tools are essential for the homeworks and projects so please make sure you grasp the basic ideas and all the tools are good to go after you follow this guide.

You will need to use ROS2 (Robot Operating System). ROS2 is easier to install and run in Linux-like systems. So this tutorial will only introduce how to install ROS2 HUmble on Ubuntu 22.04.5 Jammy Jellyfish. You are free to use other version of ROS2 if you are familiar with this framework (all variants of ROS2 share the same coding conventions). There are three ways to install Ubuntu on your pc: Virtual Machine, Dual-boot, and WSL (Windows Subsystem for Linux).

Dual-boot

Dual-boot refers to a computer setup in which two operating systems are installed on a single machine, allowing the user to choose which one to run when the computer starts up.

  1. Download an Ubuntu Image

You will need to download a ISO file for Ubuntu. Here is the link: https://releases.ubuntu.com/jammy/ Please select the 64-bit PC (AMD64) desktop image to download.

Note

If you are using macOS Applie Silicone (M1/M2), you may need to download ARM64 version https://cdimage.ubuntu.com/releases/22.04.5/release/

Here is a tutorial for installing Ubuntu 22.04 alongside Windows 11, as well as a video tutorial .

Note

incorrectly setting up a dual-boot system can lead to data loss or system malfunctions. It’s crucial to back up important data before attempting to set up a dual-boot system.

WSL (Windows Subsystem for Linux) no GUI

Note

This method only works with Windows 10 (Version 1903 or higher, with Build 18362 or higher), Windows 11 (Any version).

We follow the steps for demonstration.

  1. Turn Windows Features ON

To start, we will need to enable the Vitual Machine Platform module and Windows Subsystem for Linux feature. Open up your Start menu and locate the Turn Windows features on or off menu.

_images/wsl_step1.png
  1. Enable Virtual machine platform

Next, find the Virtual Machine Platform and Windows Subsystem for Linux options. Check both of these boxes and then press OK to enable the features.

_images/wsl_step2.png

Windows will make the changes, which may take a minute or two, then ask you to restart your system for the changes to take effect. Proceed with the reboot.

  1. Microsoft Store

When your system boots back up, go to your Start menu and find the Microsoft Store. Once there, search for Ubuntu 22.04.

_images/wsl_step3.png

Once you have located the Ubuntu 22.04 LTS page, click on the “Get” button to download it.

_images/wsl_step4.png
  1. Install Ubuntu 22.04

Once the download is complete, you can open Ubuntu 22.04 from your Start menu.

_images/wsl_step5.png

There will be an installation process that appears, and it should not take very long. The distro will be unpacked and ready to use shortly.

_images/wsl_step6.png

At this time, you will also be asked to create a new user account for Ubuntu 22.04 and some other small configuration settings.

_images/wsl_step7.png

All done. You can now open Ubuntu 22.04 from your Start menu any time you want to use it. You will be presented with a command line terminal and can execute nearly all the same commands you could on a physical Ubuntu 22.04 machine.

_images/wsl_step8.png

Play with Your Ubuntu

A successfully configured Ubuntu 22.04 looks like this:

_images/ubuntu22.04.png

Unlike Windows or MacOS, Ubuntu heavily relies on Command Line Tools. You can control your computer through typing in texts (or Commands) in the terminal. On a Ubuntu 20.04 system you can find a launcher for the terminal by clicking on the Activities item at the top left of the screen, then typing the first few letters of “terminal”, “command”, “prompt” or “shell”. Yes, the developers have set up the launcher with all the most common synonyms, so you should have no problems finding it. If you can’t find a launcher, or if you just want a faster way to bring up the terminal, most Linux systems use the same default keyboard shortcut to start it: Ctrl-Alt-T.

Install ROS2 Humble

The steps are adopted from here [Ubuntu deb packages] .

UPDATE if you meet the error 'Username' is not in the sudoers file. This incident will be reported, the steps below. Replace <username> with your username

su
sudo usermod -a -G sudo <username>
sudo adduser <username> sudo

Restart VirtualBox and continue the tutorial.

  1. Set locale

Note

You can use CTRL+ALT+T to start a new terminal.

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". We test with the following settings. However, it should be fine if you’re using a different UTF-8 supported locale.

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

Note

You can use CTRL+SHIFT+V to paste in the terminal.

  1. Setup Sources

You will need to add the ROS 2 apt repository to your system.

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

Now add the ROS 2 GPG key with apt.

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.

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
  1. Install ROS 2 packages

Update your apt repository caches after setting up the repositories.

sudo apt update

ROS 2 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.

sudo apt upgrade

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

sudo apt install ros-humble-desktop

[optional] Development tools: Compilers and other tools to build ROS packages

sudo apt install ros-dev-tools
  1. Environment setup

Add sourcing to your shell startup script

echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
  1. Try some examples

In one terminal, source the setup file and then run a C++ talker

ros2 run demo_nodes_cpp talker

In another terminal source the setup file and then run a Python listener

ros2 run demo_nodes_py listener

You should see the talker saying that it’s Publishing messages and the listener saying I heard those messages. This verifies both the C++ and Python APIs are working properly.

  1. Create a Workspace

Install colcon

sudo apt install python3-colcon-common-extensions

Create a workspace

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws

At this point the workspace contains a single empty directory src

.
└── src

1 directory, 0 files
  1. Build the workspace

In the root of the workspace, run colcon build. --symlink-install allows the installed files to be changed by changing the files in the source space (e.g. Python files or other non-compiled resources) for faster iteration.

cd ~/ros2_ws
colcon build --symlink-install

After the build is finished, we should see the build, install, and log directories

.
├── build
├── install
├── log
└── src

4 directories, 0 files
  1. Source the environment

When colcon has completed building successfully, the output will be in the install directory. Before you can use any of the installed executables or libraries, you will need to add them to your path and library paths. colcon will have generated bash/bat files in the install directory to help set up the environment. These files will add all of the required elements to your path and library paths as well as provide any bash or shell commands exported by packages.

echo "source ~/ros2_ws/install/setup.bash" >> ~/.bashrc

More to read

https://docs.ros.org/en/humble/Tutorials.html