Installing the Robotics Operating System

When you get started with robotics, you soon need a lot of software. For the serious developer or hobbyist, you are going to need it packaged neatly for some reason. The first reason is convenience, later it will be necessary because your platforms will have small memory. Being efficient becomes a necessity when you start using micro-controllers. Since ROS comes in two versions and it contains many modules, installation is trivial on the surface but can quickly become complex.

What do you need, and when?

ROS2 consists of many libraries, all of which you will install while learning. When you get more advanced, you will put only the necessary parts where you need them. To start with you will need compilers, command-line tools, and simulators. For external systems, you will want to have only the finished nodes and the communication core of the system. In the early stages, you need to try some examples and see how to simulate a robot or even several robots in action. Those tools are only available in the desktop install.

How does ROS help?

The libraries in ROS are meant to give you many standard functions for robotic activities. It has libraries for sensor handling, motor control, and much more. The focus is on the communication between nodes, which is a core concept of each function in the ROS framework.

You have options!

You can install the ros-base package with your favorite package manager. The problem is that you may use many versions of the ROS system for different projects. To avoid this problem, use a container. You will end up installing in the same way, only inside the container. The point, in the end, is that the ROS system comes in several versions and they can only run on a certain distribution version. Here is a short table:

Ubuntu Ver. ROS2 ver. ROS1 ver.
18.04 eloquent Melodic
20.04 Foxy noetic

There are more versions and more dependencies, see the list at the wiki on The point is that you have to make sure your setup supports the ROS version. ROS also uses Python to a high degree, they are testing for Python 3 (and 2.7) so you can choose. There is also a docker image available if you are more comfortable with that. The image is named ros:foxy-ros-base-focal.

Depending on what you are working with, you may need a different amount of software, which is a second reason to use containers. As you see in the table, you may also need to choose ROS1 or ROS2. If you use both, it is a big risk that settings confuse things for your compilers and other tools. The end of life for ROS1 is 2025, so don’t start new big projects with it.

Many parts inside

The Robotics Operating System has many subsystems. You need to know which one is needed where, and when you should have it installed. As soon as you start installing, you run into the choice of how much you want to install. By default, you will use your package manager to install the entire distribution. This is called ros-desktop-full, you will have all that you may need. It also takes a lot of space on your drive.

ROS Core

The ROS Core makes it possible to compile your programs through the rclcpp and rclpy client libraries. These are the two that the ROS developers maintain. More clients exist for other languages. They use the API to create consistent behavior across platforms. Included at this level are also all the ways your robotic system will communicate.

ROS Base

The ros-base includes many tools for development but contains no GUI tools.

ROS Desktop

Contains all different pieces of the system, including many examples. It also gives you all the GUI tools, including simulators and ways to test communication between nodes. The only extra things you need will be special drivers and some extra implementations of i.e. the urdf parser.

Installing ROS Desktop

The simplest way to install the ROS desktop is to use apt for Ubuntu and other Debian based distributions. On other distributions, you need to build it yourself. When you do, the result is put in a single directory structure. This means you will need to initialize that environment by sourcing the setup file. Uninstall is to remove the directory structure and stop sourcing the setup file. The sourcing you will need to do with Debian packages also.

The ROS2 packages are available as their repository at their repository. To add that to your system, copy their key.

curl -s | sudo apt-key add -

And then add their repositories.

sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] $(lsb_release -cs) main"
> /etc/apt/sources.list.d/ros2-latest.list'

When that is done, you can update and install the libraries.

sudo apt update
sudo apt install ros-foxy-desktop

With all this installed, you need to initialize the environment in the shell you are running.

source /opt/ros/foxy/setup.bash

Add this line to your .bashrc script, so all invocations of bash are ready for you to work. This is also where using a Linux container comes in handy. When you have several projects, using different versions, it is better to create a virtual machine only for ‘Foxy’ and another one for each you need.


While the basic installation is simple for ROS2, you need to be precise about what you want. If you stay with one distribution, you have no problems but start using many versions and you have complications.

About the author

Mats Tage Axelsson

I am a freelance writer for Linux magazines. I enjoy finding out what is possible under Linux and how we can all chip in to improve it. I also cover renewable energy and the new way the grid operates. You can find more of my writing on my blog.