Installing ROS Melodic

The Robot Operating System, or for short ROS, is a so called meta-operating system for robot development. Basically it is a framework including libraries, tools, modules and complete solutions to make a robot do what you want.

The easiest and most reliable way to install ROS on your machine is to install it on an Ubuntu based system. Make sure you have Ubuntu installed on your system before you proceed as this guide will be based on Ubuntu. The instructions provided in this guide are from the official ROS Melodic installation page.

Note:

The following sections will use some common commands for the bash shell. One of them is sudo which is the way to tell bash to run the given command with administrator rights. This will usually require you to type in your password. Another common command is apt which is calling the package manager. The package manager is responsible fr installing, updating and removing software from the official repositories on your system.

Installing ROS

First you need set up your computer to accept software from packages.ros.org:

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

Next you need to add the key to your system:

curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

Next you need to update the system:

sudo apt update

Now, you can install the software. There are different versions. If you want to use it for developing software on your computer, you will probably want the full package:

sudo apt install ros-melodic-desktop-full

You might get ask to confirm the installation with a [Y/n] prompt. Press enter to confirm the default action. This might take a while as the software is quite large.

Setting up the Environment

The first thing you want to do is to configure the .bashrc file. This file is a hidden (as its name starts with a dot) configuration file for the bash shell (the software running in the Terminal). The .bashrc file is read by the shell every time you open a new tab or window.

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

This command will write the source /opt/ros/melodic/setup.bash to the .bashrc file. So every time you open a new terminal window or tab, it will call the setup script to enable the ROS functionality.

Setting up the Dependencies

Before setting up the dependencies, you first need to install some software that allows you to initialize the dependencies:

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

The next thing you need to do is to initialize the ROS dependencies:

sudo apt install python-rosdep
sudo rosdep init
rosdep update

Now, the ROS environment is ready so far, but you still want to make some changes on your setup to make the use more convenient.

Setting up the Workspace

Next, you should create your workspace. ROS is using a system called catkin which is a way to organize and structure the workspace. Therefore, the workspace is usually called catkin_ws. You can create it as follows:

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make

Now that your workspace has been created, you need to initialize it:

source ~/catkin_ws/devel/setup.bash

As this needs to be done for every new terminal window and tab, you can also write this into your .bashrc file:

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc

When using the visualization tool RVIZ, I noticed some buggy behavior. This can be solved with the following. Open the .bashrc file with a text editor and add the following line at the bottom:

LC_NUMERIC="en_US.UTF-8"

This is it, you have installed ROS and set up your workspace. The software packages that you are writing need to be placed inside the /catkin_ws/src directory.