Embedded Motion Control/Tutorials/Finalizing your ROS setup

From Control Systems Technology Group
Jump to navigation Jump to search

In the previous tutorial you created the directory ~/ros/emc and used SVN to check out all software needed for this project. Now it is time to finalize the ROS set-up.

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, as was explained in a previous tutorial.

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 in an editor, for example using:

gedit ~/.bashrc

Now add the following line:

export ROS_PACKAGE_PATH=~/emc/ros:$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.

Source the '.bashrc file (using source ~/.basrc) or start a new terminal. Now again check the content of the $ROS_PACKAGE_PATH variable:

echo $ROS_PACKAGE_PATH

The result should be:

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

Now, ~/emc/ros will also be checked by ROS when looking for packages. Try it:

roscd pico_example

Should navigate you to the pico_example package. The next tutorial will explain in more detail what this roscd command does.