Embedded Motion Control/Tutorials/Installing and configuring your ROS environment

From Control Systems Technology Group
Revision as of 09:08, 29 April 2014 by S101840 (talk | contribs) (→‎Environment Set-up)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description: This tutorial walks you through installing ROS and setting up the ROS environment on your computer.

Install ROS

In this project we will use the Robotic Operating System (ROS) which aids the testing and development of robot software. ROS provides a nice open-source framework for dealing with the communication between and management of different modules, and comes with a large amount of software that can be used out of the box, including device drivers, libraries, low- and high-level software, visualizers and more. More information about ROS and its goals can be found here.

To install ROS Groovy under Ubuntu 12.04, do the following:

  1. Add the ROS Debian source to your sources.list such that Ubuntu knows where to download ROS from. Open a terminal (Applications -> Accessories -> Terminal) and enter:
    sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'
  2. To be able to connect with the server, you need to add its public key to your keys:
    wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
  3. Make sure your Debian package index is up-to-date such that you get the latest changes:
    sudo apt-get update
  4. Then, we can install ROS and some additional ROS packages we will need:
    sudo apt-get install ros-groovy-desktop ros-groovy-vision-opencv

If you ran into problems, be sure to check the installation guide on the ROS website.

Download Project Specific Software

Besides ROS, we will use some custom created packages during this project. For example, you will be able simulate the PICO robot using the pico_gazebo ROS package. To get this software, follow these steps:

  1. First, create a directory in your home directory in which you will put all ROS-related code, files and data:
    mkdir -p ~/ros/emc
  2. Then install Subversion (SVN), a file share and versioning tool similar to Dropbox that we will use during this project:
    sudo apt-get install subversion
    It may be the case that this tool is already installed on your system.
  3. Navigate into the folder you created:
    cd ~/ros/emc
  4. Check-out the PICO-software:
    svn co https://roboticssrv.wtb.tue.nl/svn/emc/2014/general
    Validate the certificate by pressing p (permanently). You will then be prompted for your username and password. Use the account credentials that were sent to your group. The term check-out is SVN-terminology for downloading. More information on SVN will be provided later.
  5. Check-out your group folder. This is the directory you and your group will be working in:
    svn co https://roboticssrv.wtb.tue.nl/svn/emc/2014/groups/emc<YOUR_GROUP_NUMER>     # i.e., emc01, emc02, etc
    You will see the directory is initially empty or, if a group member has already started the tutorials, will contain some of his files.

Environment Set-up

So far we've installed ROS and created a local copy of the SVN. However, before you can start working, you need to do some additional set-ups to make sure Ubuntu knows where to find all ROS-related packages, scripts, etc. More specifically, every time you start up a terminal, the correct environment variables need to be set. The file .bashrc in your home directory is your friend: it's a script which runs every time a a new terminal is opened. We basically need to add some lines to this file, so open the file with a text editor:

gedit ~/.bashrc

Append the following text to the end of the file:

source /opt/ros/groovy/setup.bash

and save and exit. Next time you open a terminal, .bashrc is executed, which will in turn source ROS' setup.bash and setup all ROS-related scripts, etc. Since .bashrc is only called when a new terminal is opened, the changes are not active in your current terminal. If you want to see it working directly without starting a new terminal, explicitly source .bashrc from the terminal:

source ~/.bashrc

ROS uses a set of environment variables to keep track of where ROS packages are located, which ROS versions is used, etc. Think of an environment variable as a variable containing some information that is needed throughout your terminal session. Those environment variables are typically set when .bashrc is sourced.

One important ROS environment variable is your ROS_PACKAGE_PATH. This contains the paths ROS will inspect while looking for a package or stack (e.g. when you use roscd), separated by colons. To check your ROS package path, type the following in a terminal:

echo $ROS_PACKAGE_PATH

It will return:

/opt/ros/groovy/share:/opt/ros/groovy/stacks

Which means currently two directories are used by ROS: /opt/ros/groovy/share and /opt/ros/groovy/stacks. This means the packages that were checked out into ~/ros/emc cannot be found by ROS. Fortunately, we can change this. Open ~/.bashrc again in an editor:

gedit ~/.bashrc

Now add the following line after the previous line that was added:

export ROS_PACKAGE_PATH=~/ros/emc:$ROS_PACKAGE_PATH

When this statement is executed, the text $ROS_PACKAGE_PATH is replaced by the actual value of this variable (we used this above to check the content using the echo command). This means that the variable is pre-pended by ~/emc/ros when this statement is executed.

Now source your .bashrc again:

source ~/.bashrc

and check if the ROS_PACKAGE_PATH is indeed updated:

echo $ROS_PACKAGE_PATH

should return:

/home/YOUR_NAME/ros/emc:/opt/ros/groovy/share:/opt/ros/groovy/stacks

That's it. Now ROS will also look for ROS packages into ~/ros/emc. For example, you can now change your directory to the pico_gazebo package that was downloaded with SVN:

roscd pico_gazebo

should take you to ~/ros/emc/general/pico_gazebo.

The next tutorial will explain a bit more about roscd and some other ROS tools.