Robot Operating System (ROS)
The Robot Operating System (ROS) is a flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms.
Note: "The robot operating system" is actually not an operating system the the traditional sense, but rather a middleware that runs on top of an the Ubuntu operating system. Each version of ROS depends on a specific version of Ubuntu. In this course, we will use the version of ROS2 named Humble Hawksbill (aka "Humble") which runs on Ubuntu 22.04.
ROS Installation
Skip to the installation instructions for your operating system: - Install ROS 2 on Ubuntu 22.04 - Install ROS 2 on MacOS - Install ROS 2 on Windows
This portion of the guide will walk you through the steps to install ROS 2 on your development machine. ROS 2 is the Robot Operating System that provides libraries and tools to help software developers create robot applications.
We are using the version of ROS 2 named Humble Hawksbill. This version of ROS2 only officially supports installation on Ubuntu 22.04 (Jammy Jellyfish). However, it is possible to install ROS2 on other operating systems (Windows and MacOS) using Docker containers, virtual machines, or the pixi package manager and the robostack project.
Install ROS 2 on Ubuntu 22.04
Follow the official ROS 2 Humble installation instructions for Ubuntu 22.04: Install ROS2 on Ubuntu 22.04. The steps are summarized below:
# setup locale
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
# add the repository
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y
export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}')
curl -L -o /tmp/ros2-apt-source.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo ${UBUNTU_CODENAME:-${VERSION_CODENAME}})_all.deb"
sudo dpkg -i /tmp/ros2-apt-source.deb
# install ROS 2 packages
sudo apt update
sudo apt upgrade
sudo apt install ros-humble-desktop ros-dev-tools
Using ROS2 on Ubuntu
To use ROS2, you need to source the ROS2 setup script in each terminal session. You can do this by running the following command:
source /opt/ros/humble/setup.bash
Install ROS 2 on MacOS
You can install ROS2 Humble on MacOS using the pixi package manager and the robostack project.
If you don't have
pixiinstalled, first runcurl -fsSL https://pixi.sh/install.sh | sh
Then, install ROS2 Humble with the following commands:
cd
pixi init robostack
cd robostack
curl -L https://gist.githubusercontent.com/nathantsoi/460cbfa3a75d9d6f751852f703b92650/raw/pixi.toml -o pixi.toml
pixi install
Then, start a shell with ROS2 Humble sourced:
pixi shell -e humble
Using ROS2 on MacOS
Before running ROS2 commands, ensure that you are in the pixi shell with the correct environment by running
cd ~/robostack && pixi shell -e humble, then standard ROS2 commands will work as expected:
rviz2
Install ROS 2 on Windows
Using ROS2 on Windows
ROS2 Concepts
- Nodes: The basic building blocks of a ROS2 system. Each node is a separate process that performs a specific function. For example, a node might read data from a sensor, process that data, or control an actuator.
- Topics: A publish/subscribe messaging system that allows nodes to communicate with each other asynchronously. For example, a sensor node might publish data to a topic, and a processing node might subscribe to that topic to receive the data. Topics names are typically in the format of
/namespace/topic_name. - Messages: The data structures used for communication between nodes.
- Services: A request/reply messaging system that allows nodes to communicate synchronously.
- Packages: A collection of nodes, messages, services, and other resources that are organized together.
Working with ROS2
ROS projects are organized into packages. All packages for the project are placed in a workspace. This workspace is a folder in the home directory of the user. The workspace we'll use for the car is roboracer_ws. Within this workspace, there is a src directory where all the ROS2 packages are stored.
Each package contains nodes, message definitions, and other resources needed for a specific functionality.
ROS2 Tutorials
If you're not familiar with ROS2, it is highly recommended that you complete the following ROS2 tutorials. These tutorials should be completed on your computer, not on the car.