Embedded Motion Control/Tutorials/Installing and configuring your ROS environment: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
No edit summary
 
(14 intermediate revisions by one other user not shown)
Line 11: Line 11:
# Make sure your Debian package index is up-to-date such that you get the latest changes:<pre>sudo apt-get update</pre>
# Make sure your Debian package index is up-to-date such that you get the latest changes:<pre>sudo apt-get update</pre>
# Then, we can install ROS and some additional ROS packages we will need:<pre>sudo apt-get install ros-groovy-desktop ros-groovy-vision-opencv</pre>
# Then, we can install ROS and some additional ROS packages we will need:<pre>sudo apt-get install ros-groovy-desktop ros-groovy-vision-opencv</pre>
# Furthermore, you will need some additional ROS packages:<pre>sudo apt-get install ros-fuerte-pr2-controllers ros-fuerte-vision-opencv</pre>


If you ran into problems, be sure to check the [http://www.ros.org/wiki/groovy/Installation/Ubuntu installation guide on the ROS website].
If you ran into problems, be sure to check the [http://www.ros.org/wiki/groovy/Installation/Ubuntu installation guide on the ROS website].


= Create a ROS Workspace =  
= Download Project Specific Software =


TODO
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:
 
# First, create a directory in your home directory in which you will put all ROS-related code, files and data: <pre>mkdir -p ~/ros/emc</pre>
# Then install Subversion (SVN), a file share and versioning tool similar to Dropbox that we will use during this project:<pre>sudo apt-get install subversion</pre>It may be the case that this tool is already installed on your system.
# Navigate into the folder you created:<pre>cd ~/ros/emc</pre>
# ''Check-out'' the PICO-software:<pre>svn co https://roboticssrv.wtb.tue.nl/svn/emc/2014/general</pre>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.
# ''Check-out'' your group folder. This is the directory you and your group will be working in:<pre>svn co https://roboticssrv.wtb.tue.nl/svn/emc/2014/groups/emc<YOUR_GROUP_NUMER>    # i.e., emc01, emc02, etc</pre>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:
 
<pre>gedit ~/.bashrc</pre>
 
Append the following text to the end of the file:
 
<pre>source /opt/ros/groovy/setup.bash</pre>
 
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:
 
<pre>source ~/.bashrc</pre>
 
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:


<pre>echo $ROS_PACKAGE_PATH</pre>
<pre>echo $ROS_PACKAGE_PATH</pre>
You should see something similar to:


<pre>
It will return:
/home/your_user_name/fuerte_workspace/sandbox:/opt/ros/fuerte/share:/opt/ros/fuerte/stacks
 
</pre>
:<pre>/opt/ros/groovy/share:/opt/ros/groovy/stacks</pre>
 
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:
 
<pre>gedit ~/.bashrc</pre>
 
Now add the following line after the previous line that was added:
 
<pre>export ROS_PACKAGE_PATH=~/ros/emc:$ROS_PACKAGE_PATH</pre>
 
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:
 
<pre>source ~/.bashrc</pre>
 
and check if the ROS_PACKAGE_PATH is indeed updated:
 
<pre>echo $ROS_PACKAGE_PATH</pre>
 
should return:
 
:<pre>/home/YOUR_NAME/ros/emc:/opt/ros/groovy/share:/opt/ros/groovy/stacks</pre>
 
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:
 
<pre>roscd pico_gazebo</pre>
 
should take you to ''~/ros/emc/general/pico_gazebo''.
 
The [[ Embedded Motion Control/Tutorials/Navigating the ROS filesystem | next tutorial ]] will explain a bit more about ''roscd'' and some other ROS tools.

Latest revision as of 09:08, 29 April 2014

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.