Book Image

ROS Robotics By Example

Book Image

ROS Robotics By Example

Overview of this book

The visionaries who created ROS developed a framework for robotics centered on the commonality of robotic systems and exploited this commonality in ROS to expedite the development of future robotic systems. From the fundamental concepts to advanced practical experience, this book will provide you with an incremental knowledge of the ROS framework, the backbone of the robotics evolution. ROS standardizes many layers of robotics functionality from low-level device drivers to process control to message passing to software package management. This book provides step-by-step examples of mobile, armed, and flying robots, describing the ROS implementation as the basic model for other robots of these types. By controlling these robots, whether in simulation or in reality, you will use ROS to drive, move, and fly robots using ROS control.
Table of Contents (17 chapters)
ROS Robotics By Example
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

ROS packages and manifest


The ROS software is divided into packages that can contain various types of programs, images, data, and even tutorials. The specific contents depend on the application for the package. The site http://wiki.ros.org/Packages discusses ROS packages.

A package can contain programs written in Python or C++ to control a robot or another device. For the turtlesim simulator package for example, the package contains the executable code used to change the background color or move a turtle around on the screen. This package also contains images of a turtle for display and files used to create the simulator.

There is another class of packages in ROS called metapackages that are specialized packages that only contain a package.xml manifest. Their purpose is to reference one or more related packages, which are loosely grouped together.

ROS manifest

Each package contains a manifest named package.xml that describes the package in the Extensible Markup Language (XML) format. In addition to providing a minimal specification describing the package, the manifest defines properties about the package such as the package name, version numbers, authors, maintainers, and dependencies on other packages.

Exploring the ROS packages

Occasionally, we would like to find packages that we wish to use and display the files involved. This section introduces several useful ROS commands:

  • rospack used for information about a package

  • roscd used to navigate the ROS directories

  • rosls used to list directories and files in a package directory

The rospack command can be used to list ROS packages, locate packages by name, and determine if a package depends on another package, among other uses. For more information use the following command with the help or -h option in the form:

$ rospack help | less

Tip

There are many options for this command, so piping with the less option shows one screen at a time. For many commands, using the power of Linux to make the output readable is necessary. Use the Q key to quit (exit) the mode.

We will use the turtlesim package for the examples here. To change directories to the location of turtlesim, use the following command:

$ roscd turtlesim

This yields the location to one of the author's laptops as follows:

harman@Laptop-M1210:/opt/ros/indigo/share/turtlesim$

On your computer, the $ command prompt will be preceded by the information about your computer. Generally, that information for our computers will be deleted in our examples using ROS commands. Once you are in the turtlesim directory, the standard Linux commands can be used with the subdirectories or files, or the ROS commands can be used. To determine the directories and files in the turtlesim directory but without changing to the turtlesim directory, use the following command:

$ rosls turtlesim

Here is the result from the home directory of the author's laptop with ROS installed:

cmake  images  msg  package.xml  srv

To see the filenames of the images loaded with turtlesim, specify the images directory in the package as follows:

$ rosls turtlesim/images

The output of the preceding command is as follows:


box-turtle.png            fuerte.png       hydro.svg       palette.png          turtle.png

diamondback.png     groovy.png     indigo.png     robot-turtle.png

electric.png                 hydro.png       indigo.svg      sea-turtle.png

There are various turtle images that can be used. The rosls turtlesim command will also work to show the contents of the turtlesim subdirectories: /msg for messages and /srv for services. These files will be discussed later. To see the manifest, type the following command:

$ roscd turtlesim
$ cat package.xml

This will also show the dependencies such as roscpp for C++ programs.

rospack find packages

The rospack find <package name> command returns the path to the package named <package name>. For example, type the following command:

$ rospack find turtlesim

The preceding command displays the path to the turtlesim directory.

rospack list

Execute the following command:

$ rospack list

This lists the ROS package names and their directories on the computer. In the case of the laptop mentioned earlier, there are 225 ROS packages listed!

Tip

If you really want to see all the ROS packages and their locations, use the following command form:

$ rospack list | less

This form allows paging of the long list of names and directories for the packages. Press Q to quit.

Alternatively, this is the form of the rospack command:

$ rospack list-names

This lists only the names of the packages without the directories. After such a long list, it is a good idea to open a new terminal window or clear the window with the clear command.

This is the form of the rospack command:

$ rospack list-names | grep turtle

This lists the four packages with turtle in the name.

More information on commands that are useful to navigate the ROS filesystem is available at the ROS website http://wiki.ros.org/ROS/Tutorials/NavigatingTheFilesystem.