Book Image

Learning ROS for Robotics Programming

By : Aaron Martinez, Enrique Fernández
Book Image

Learning ROS for Robotics Programming

By: Aaron Martinez, Enrique Fernández

Overview of this book

<p>Both the amateur and the professional roboticist who has ever tried their hand at robotics programming will have faced with the cumbersome task of starting from scratch, usually reinventing the wheel. ROS comes with a great number of already working functionalities, and this book takes you from the first steps to the most elaborate designs possible within this software framework.</p> <p>"Learning ROS for Robotics Programming" is full of practical examples that will help you to understand the framework from the very beginning. Build your own robot applications in a simulated environment and share your knowledge with the large community supporting ROS.</p> <p>"Learning ROS for Robotics Programming" starts with the basic concepts and usage of ROS in a very straightforward and practical manner. It is a painless introduction to the fascinating world of robotics, covering sensor integration, modeling, simulation, computer vision, and navigation algorithms, among other topics.</p> <p>After the first two chapters, concepts like topics, messages, and nodes will become daily bread. Make your robot see with HD cameras, or navigate avoiding obstacles with range sensors. Furthermore, thanks to the contributions of the vast ROS community, your robot will be able to navigate autonomously, and even recognize and interact with you, in a matter of minutes.</p> <p>"Learning ROS for Robotics Programming" will give you all the background you need to know in order to start in the fascinating world of robotics and program your own robot. Simply, you put the limit!</p>
Table of Contents (16 chapters)
Learning ROS for Robotics Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Learning ROS for Robotics Programming gives you a comprehensive review of ROS tools. ROS is the Robot Operating System framework, which is used nowadays by hundreds of research groups and companies in the robotics industry. But it is also the painless entry point to robotics for nonprofessional people. You will see how to install ROS, start playing with its basic tools, and you will end up working with state-of-the-art computer vision and navigation tools.

The content of the book can be followed without any special devices, and each chapter comes with a series of source code examples and tutorials that you can run on your own computer. This is the only thing you need to follow in the book. However, we also show you how to work with hardware, so that you can connect your algorithms with the real world. Special care has been taken in choosing devices which are affordable for amateur users, but at the same time the most typical sensors or actuators in robotics research are covered.

Finally, the potential of ROS is illustrated with the ability to work with whole robots in a simulated environment. You will learn how to create your own robot and integrate it with the powerful navigation stack. Moreover, you will be able to run everything in simulation, using the Gazebo simulator. We will end the book by providing a list of real robots available for simulation in ROS. At the end of the book, you will see that you can work directly with them and understand what is going on under the hood.

What this book covers

Chapter 1, Getting Started with ROS, shows the easiest way you must follow in order to have a working installation of ROS. You will see how to install different distributions of ROS, and you will use ROS Fuerte in the rest of the book. How to make an installation from Debian packages or compiling the sources, as well as making installations in virtual machines, have been described in this chapter.

Chapter 2, The ROS Architecture with Examples, is concerned with the concepts and tools provided by the ROS framework. We will introduce you to nodes, topics, and services, and you will also learn how to use them. Through a series of examples, we will illustrate how to debug a node or visualize the messages published through a topic.

Chapter 3, Debugging and Visualization, goes a step further in order to show you powerful tools for debugging your nodes and visualize the information that goes through the node's graph along with the topics. ROS provides a logging API which allows you to diagnose node problems easily. In fact, we will see some powerful graphical tools such as rxconsole and rxgraph, as well as visualization interfaces such as rxplot and rviz. Finally, this chapter explains how to record and playback messages using rosbag and rxbag.

Chapter 4, Using Sensors and Actuators with ROS, literally connects ROS with the real world. This chapter goes through a number of common sensors and actuators that are supported in ROS, such as range lasers, servo motors, cameras, RGB-D sensors, and much more. Moreover, we explain how to use embedded systems with microcontrollers, similar to the widely known Arduino boards.

Chapter 5, 3D Modeling and Simulation, constitutes one of the first steps in order to implement our own robot in ROS. It shows you how to model a robot from scratch and run it in simulation using the Gazebo simulator. This will later allow you to use the whole navigation stack provided by ROS and other tools.

Chapter 6, Computer Vision, shows the support for cameras and computer vision tasks in ROS. This chapter starts with drivers available for FireWire and USB cameras, so that you can connect them to your computer and capture images. You will then be able to calibrate your camera using ROS calibration tools. Later, you will be able to use the image pipeline, which is explained in detail. Then, you will see how to use several APIs for vision and integrate OpenCV. Finally, the installation and usage of a visual odometry software is described.

Chapter 7, Navigation Stack – Robot Setups, is the first of two chapters concerned with the ROS navigation stack. This chapter describes how to configure your robot so that it can be used with the navigation stack. In the same way, the stack is explained, along with several examples.

Chapter 8, Navigation Stack – Beyond Setups, continues the discussion of the previous chapter by showing how we can effectively make our robot navigate autonomously. It will use the navigation stack intensively for that. This chapter shows the great potential of ROS using the Gazebo simulator and rviz to create a virtual environment in which we can build a map, localize our robot, and do path planning with obstacle avoidance.

Chapter 9, Combining Everything – Learn by Doing, builds from the previous chapters and shows a number of robots which are supported in ROS using the Gazebo simulator. In this chapter you will see how to run these robots in simulation and perform several of the tasks learned in the rest of the book, especially those related to the navigation stack.

What you need for this book

This book was written with the intention that almost everybody can follow it and run the source code examples provided with it. Basically, you need a computer with a Linux distribution. Although any Linux distribution should be fine, it is recommended that you use a recent version of Ubuntu. Then you will use ROS Fuerte, which is installed according to the instructions given in Chapter 1, Getting Started with ROS. For this distribution of ROS, you will need a version of Ubuntu prior to 12.10 because since this version Fuerte is no longer supported.

Regarding the hardware requirements of your computer, in general any computer or laptop is enough. However, it is advisable to use a dedicated graphic card in order to run the Gazebo simulator. Also, it will be good to have a good number of peripherals, so that you can connect several sensors and actuators, including cameras and Arduino boards.

You will also need Git (the git-core Debian package) in order to clone the repository with the source code provided with this book. Similarly, you are expected to have a basic knowledge of the Bash command line, GNU/Linux tools, and some C/C++ programming skills.

Who this book is for

This book is targeted at all robotics developers, from amateurs to professionals. It covers all the aspects involved in a whole robotic system and shows how ROS helps with the task of making a robot really autonomous. Anyone who is learning robotics and has heard about ROS but has never tried it will benefit from this book. Also, ROS beginners will learn advance concepts and tools of this framework. Indeed, even regular users may learn something new from some particular chapters. Certainly, only the first three chapters are intended for new users; so those who already use ROS may skip these ones and go directly to the rest.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meanings.

Code words in text are shown as follows: "The *-ros-pkg contributed packages are licensed under a variety of open source licenses."

A block of code is set as follows:

<package>
  <description brief="short description">
    long description, 
  </description>
  <author>Aaron Martinez, Enrique Fernandez</author>
  <license>BSD</license>
  <url>http://example.com/</url>
 
  <depend package="roscpp"/>
  <depend package="common"/>
  <depend package="otherPackage"/>
  <versioncontrol type="svn" url="https://urlofpackage/trunk"/>
  <export>
    <cpp cflags="-I${prefix}/include" lflags="-L${prefix}/lib -lros"/>
</package>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<launch>
<node pkg="chapter3_tutorials" type="example1"
            name="example1" output="screen"
            launch-prefix="xterm -e gdb --args"/>
</launch>

Any command-line input or output is written as follows:

$ rosrun book_tutorials tutorialX _param:=9.0

New terms and important words are shown in bold. Words that you see on the screen, in menus, or dialog boxes for example, appear in the text like this: "We must have clicked on the Play button at least once."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. You can also download these code files from https://github.com/AaronMR/Learning_ROS_for_Robotics_Programming.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams

used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/1448OS_Graphics.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.