Book Image

ROS Robotics By Example, Second Edition - Second Edition

By : Carol Fairchild, Lentin Joseph, Dr. Thomas L. Harman
Book Image

ROS Robotics By Example, Second Edition - Second Edition

By: Carol Fairchild, Lentin Joseph, Dr. Thomas L. Harman

Overview of this book

ROS is a robust robotics framework that works regardless of hardware architecture or hardware origin. It standardizes most layers of robotics functionality from device drivers to process control and message passing to software package management. But apart from just plain functionality, ROS is a great platform to learn about robotics itself and to simulate, as well as actually build, your first robots. This does not mean that ROS is a platform for students and other beginners; on the contrary, ROS is used all over the robotics industry to implement flying, walking and diving robots, yet implementation is always straightforward, and never dependent on the hardware itself. ROS Robotics has been the standard introduction to ROS for potential professionals and hobbyists alike since the original edition came out; the second edition adds a gradual introduction to all the goodness available with the Kinetic Kame release. By providing you with step-by-step examples including manipulator arms and flying robots, the authors introduce you to the new features. The book is intensely practical, with space given to theory only when absolutely necessary. By the end of this book, you will have hands-on experience on controlling robots with the best possible framework.
Table of Contents (18 chapters)
ROS Robotics By Example Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
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 any 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

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 changes the location on one of the author's workstations as follows:

linux@D158-45929:/opt/ros/kinetic/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 workstation 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   groovy.png  indigo.svg   palette.png
diamondback.png  hydro.png   jade.png     robot-turtle.png
electric.png     hydro.svg   kinetic.png  sea-turtle.png
fuerte.png       indigo.png  kinetic.svg  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 commands:

$ 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 workstation mentioned earlier, there are 195 ROS packages listed!

Note

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 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