The Robot Operating System (ROS) is a set of software libraries and tools for building robot applications.

OS Requirement

  1. OS: Linux
  2. Distro: Ubuntu/RHEL
  3. Shell: Bash

Installation Procedure:

My OS Specification

  1. OS: Linux
  2. Distro: Fedora 38
  3. Shell: Bash

Used Tools

Packages used to run ROS2 on distributions other than the supported ones.

Ubuntu 22.04 Container

Installation Procedure

  1. Install docker, podman, and distrobox.
  2. Run the following command to make a distro container for Ubuntu 22.04:
distrobox-create --name ros --image ubuntu:22.04
  1. Log inside the created container:
distrobox enter ros
  1. Install the ROS2 distribution following the instruction for ubuntu 22.04 inside the container.

Example Usage

  1. Log inside the ubuntu container we just created by:
distrobox enter ros
  1. In one ros container terminal, source the setup file and then run a C++ talker:
source /opt/ros/humble/setup.bash
ros2 run demo_nodes_cpp talker
  1. In another ros container terminal, source the setup file and then run a Python listener:
source /opt/ros/humble/setup.bash
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. yayyyy!

Additional Setup

  1. ROS requires the setup.bash file to be sourced every time before running it. This can be automated by adding the following line in your .bashrc .
source /opt/ros/humble/setup.bash
  1. This might cause error on the host terminal because the /opt/ros/humble/setup.bash is only on the container.
# Error: bash: /opt/ros/humble/setup.bash: No such file or directory
  1. To fix that add the following snippet at the end of your .bashrc file instead of the above mentioned line.
if [ "$(grep Ubuntu /etc/issue | awk '{print $1}')" == "Ubuntu" ]; then
	source /opt/ros/humble/setup.bash
  1. The clear command might not work inside the container, to fix that run the following command on your terminal. (It adds export TERM=linux in your .bash_profile)
echo 'export TERM=linux' >> ~/.bash_profile
  1. We need to log into the container every time we launch a new terminal so it’s better to make a shortcut to log straight to the container terminal.
# For most terminals the shortcut can be set as:
<terminal-name> -e distrobox enter ros