Link Search Menu Expand Document


Installing ROS

Table of contents

  1. Getting started with ROS
  2. Installing ROS
    1. Setup repositories
    2. Installation
    3. Environment setup
    4. Dependencies for building packages
    5. Initialization

Getting started with ROS

The Robot Operating System (ROS) is a crucial middleware (a.k.a. collection of software packages) that enables roboticists all over the world to implement their algorithms in a clean and modular fashion and share their work effectively with the community.

In addition, it is at the very core of our class, so we’d better start playing with it!

Installing ROS

By now, you should have a working (preferably fresh) install of Ubuntu 18.04 and have become accustomed with the basics of Linux, Git and C++. The most efficient way to install ros is through the Debian (binary) packages.

To install ROS Melodic on it, we will follow the official guide to install the Desktop-Full Install option.

Setup repositories

Let’s add the repository to our system

sudo sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

and setup the keys

sudo apt-key adv --keyserver 'hkp://' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654


Before installing ROS we need to update the apt index

sudo apt update

Now let’s install ROS 🤖

sudo apt install ros-melodic-desktop-full

Note: if you encounter the following problem when running the command line above:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ros-melodic-desktop-full : Depends: ros-melodic-perception but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Then a solution is to instead of running sudo apt install ros-melodic-desktop-full, perform the following:

sudo apt install aptitude
sudo aptitude install ros-melodic-desktop-full

Environment setup

It’s convenient if the ROS environment variables are automatically loaded as soon a new shell is launched, let’s edit ~/.bashrc to do so

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

Dependencies for building packages

Up to now you have installed what you need to run the core ROS packages. To create and manage your own ROS workspaces, there are various tools and requirements that are distributed separately. For example, rosinstall is a frequently used command-line tool that enables you to easily download many source trees for ROS packages with one command.

To install this tool and other dependencies for building ROS packages, run:

sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential python-catkin-tools rosbash


Before using ROS, we need to initialize rosdep.

sudo rosdep init
rosdep update

Copyright © 2018-2022 MIT. This work is licensed under CC BY 4.0