One month ago, I wrote a post with all the reasons that should make you use ROS to design and build robots. In this tutorial, I will show you the end-to-end process to have a fresh ROS environment on a Linux Ubuntu machine.
I know you can read this guide and get all the information to install ROS Indigo on a Linux machine without any problem. But this guide may be incomplete for someone who wants to install ROS on a virtual machine and setting up the creation of an ROS workspace.
Probably the best books to learn ROS
The tutorial has four parts:
- In the first part, I’ll show you how to install and setup Linux Ubuntu under Oracle VM VirtualBox. This part is very useful if you’re using a Windows PC or Mac OS. If you already use a Linux Ubuntu machine, then you can jump directly to the second part of the tutorial.
- In the second part of the tutorial, I’ll show you how to install ros-indigo-desktop-full on Linux Ubuntu.
- In the third part, you’ll see how to install external packages needed to start working with ROS.
- In the last part, I’ll show you how to check your ROS environment.
1. How to Install a virtual machine and setup Linux Ubuntu
The first step to having a fresh installed Linux Ubuntu on a Windows or Mac OS machine is to install a virtual machine. There are various software for virtual machines and some of these are free. I choose to work with an Oracle VM VirtualBox because is free and meets the requirements of the system. You have comprehensive documentation to work with it and a lot of possibilities to configure.
Below are the steps to install the VM and run Linux Ubuntu 14.04 on it.
2. How to Install ros-indigo-desktop-full on Linux Ubuntu
In the first part, I show you how to install a virtual machine and setup Linux Ubuntu on it. In this part, I will start to explore the main core of this tutorial – ROS Indigo.
ROS has many distributions named using adjectives such as Hydro, Fuerte, Electric, etc. Our subject is called Indigo and is one of the most used distributions released by the Open Source Robotics Foundation. Indigo was released as long-term services and is supposed to have the lifetime until April 2019. Also, it is the ROS distribution recommended for the situation where the user needs stability. And because I talked about stability, is recommended to use ROS Indigo with Linux Ubuntu 14.04.
Below are all the steps to install ROS Indigo on Ubuntu 14.04.
2.1 Configure Ubuntu repository
This step doesn’t have something in common with ROS, but we have to do it to allow different official software repositories: main, restricted, universe and multiverse.
Step 1: Click on the Ubuntu Software Center
Step 2: Select Software Source…
Step 3: Select all the checkboxes as in the below image
2.2 Set up the computer to accept software from packages.ros.org
We have to setup the source.list file on the Linux machine. This action allows the computer to accept software from the authorized ROS site packages.ros.org.
Step: Open a new Terminal and type the following command:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
2.3 Set up your keyserver that allow ROS to install software
Step: In the Terminal, type the following command:
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
2.4 Updates the file that Ubuntu uses to get software
Step: In the Terminal, type the following command that updates the file that Ubuntu uses to get the software. This step will make you avoid problems with versions of software.
sudo apt-get update
2.5 Finally, install ROS Indigo
Step: In the Terminal, type the following command to download and install ROS Indigo files. This step will take several minutes.
sudo apt-get install ros-indigo-desktop-full
3. Install external packages
In the previous part, you should be finished the ROS Indigo installation. But, before you start writing the first ROS code, you need to initialize rosdep, set up the ROS environment variables and make your work easier with rosinstall.
3.1 Initialize rosdep that enables you install system dependencies
Step 1: In the Terminal, type the following command:
sudo rosdep init
Step 2: And then is recommended to run the command:
3.2 Set up the ROS environment variables
Your system should know about ROS files when you will execute ROS command-line commands. To automatically add to your session the ROS environment variables, type the following command:
Step: in the Terminal, run the following script:
echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
3.3 Install rosinstall
This is a tool in ROS that allows you to download ROS packages.
Step: Type the following command in the Terminal:
sudo apt-get install python-rosinstall
4. Create a catkin workspace and check your ROS environment
catkin is the build system of ROS and combines CMake macros and Python scripts to provide particular functionality on top of CMake’s normal workflow. In the catkin workspace folder you can create and modify the ROS code.
Step 1: To create the catkin folder, type the following commands:
mkdir -p ~/catkin_ws/src
If you type “ls” in the catkin_ws folder, you should see the folders “build”, “devel” and “src.”
Step 2: You need to add this workspace on top of your ROS environment. Type the following commands:
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
Step 3: Check the ROS environment variables
export | grep ROS
You should see something like:
Step 4: Check the ROS path environment variables
In Terminal, you should see something like this:
Step 5: And finally, check ROS with the following command:
After a lot of steps and checks, finally you should have a fresh ROS environment on a Linux machine where you can design and test robots.