When working with ROS source code, it is often useful to do so in a "workspace". For the following ROS tutorials you will need an area for working on tutorials and creating new ROS stacks and packages.
rosws is a tool that provides a uniform interface to various version control systems such as SVN, Git and Mercurial and for managing all packages installed in a ROS overlay. An extensive tutorial on rosws can be found http://www.ros.org/doc/independent/api/rosinstall/html/rosws_ros_tutorial.html#rosws-ros-tutorial
$ cd
The following command creates a new groovy overlay workspace in ~/groovy_workspace:
$ rosws init ~/groovy_workspace /opt/ros/groovy/
Note
This command does nothing else than to create the folder ~/groovy_workspace, the files setup.bash, setup.sh, setup.zsh and the hidden file .rosinstall in the directory ~/groovy_workspace.
init option set up a directory as workspace
Usage: rosws init TARGET_PATH SOURCE_PATH
rosws init does the following:
Reads folder/file/web-uri SOURCE_PATH looking for a rosinstall yaml
Creates new .rosinstall file at TARGET-PATH configured
Generates ROS setup files
SOURCE_PATH can e.g. be a folder like /opt/ros/groovy If PATH is not given, uses current folder.
We will use ~/groovy_workspace from now on.
The next step is to source the setup.bash in ~/groovy_workspace:
$ source ~/groovy_workspace/setup.bash
Note
You can only source one workspace at a time. It is generally error prone to switch from one workspace to another, this can cause confusing errors. Prefer to keep the same workspace in the same terminal. If you work with several workspaces, do not source any of them in your .bashrc.
It is very common to replace the line source source /opt/ros/groovy/setup.bash in the .bashrc to the command above, so that whenever you create a new terminal, that environment is used.
You can verify the workspace using again rosws info:
$ rosws info workspace: ~/groovy_workspace ROS_ROOT: /opt/ros/groovy/share/ros
New packages need to be put in a path that is in the variable ROS_PACKAGE_PATH. All directories that are managed by rosws, i.e. that have been added using rosws are automatically added to the ROS_PACKAGE_PATH when the file setup.bash of the corresponding workspace is sourced. Although new packages should always be put in repositories that have been installed using rosws, it can be very convenient to have a sandbox directory where for instance packages created during the tutorials can be put without requiring any additional rosws commands. For that we create a new directory sandbox and add it to the .rosinstall file:
$ mkdir ~/groovy_workspace/sandbox $ rosws set ~/groovy_workspace/sandbox
Note
set option add or changes one entry from your workspace config. The command will infer whether you want to add or modify an entry. The command only changes the configuration, to checkout or update the element, run rosws update afterwards.
Usage: rosws set [localname] [SCM-URI]? [--(detached|svn|hg|git|bzr)] [--version=VERSION]]
Now, it is necessary to re-source ~/groovy_workspace/setup.bash to make sure that the updated ROS_PACKAGE_PATH is used:
$ source ~/groovy_workspace/setup.bash
You can verify the workspace using again rosws info:
$ cd ~/groovy_workspace $ rosws info workspace: ~/groovy_workspace ROS_ROOT: /opt/ros/groovy/share/ros Localname S SCM Version-Spec UID (Spec) URI (Spec) [http(s)://...] --------- - ---- ------------ ----------- --------------------------- sandbox