Preface

ROS, the Robot Operating System, is an open source framework for getting robots to do things. ROS is meant to serve as a common software platform for people who are building and using robots. This common platform lets people share code and ideas more readily and, perhaps more importantly, means that you do not have to spend years writing software infrastructure before your robots start moving!

ROS has been remarkably successful. At the time of writing, in the official distribution of ROS, there are over 2,000 software packages, written and maintained by almost 600 people. Approximately 80 commercially available robots are supported, and we can find at least 1,850 academic papers that mention ROS. We no longer have to write everything from scratch, especially if we’re working with one of the many robots that support ROS, and can spend more time thinking about robotics, rather than bit-fiddling and device drivers.

ROS consists of a number of parts:

  1. A set of drivers that let you read data from sensors and send commands to motors and other actuators, in an abstracted, well-defined format. A wide variety of popular hardware is supported, including a growing number of commercially available robot systems.

  2. A large and growing collection of fundamental robotics algorithms that allow you to build maps of the world, navigate around it, represent and interpret sensor data, plan motions, manipulate objects, and do a lot of other stuff. ROS has become very popular in the robotics research community, and a lot of cutting-edge algorithms are now available in ROS.

  3. All of the computational infrastructure that allows you to move data around, to connect the various components of a complex robot system, and to incorporate your own algorithms. ROS is inherently distributed and allows you to split the workload across multiple computers seamlessly.

  4. A large set of tools that make it easy to visualize the state of the robot and the algorithms, debug faulty behaviors, and record sensor data. Debugging robot software is notoriously difficult, and this rich set of tools is one of the things that make ROS as powerful as it is.

  5. Finally, the larger ROS ecosystem includes an extensive set of resources, such as a wiki that documents many of the aspects of the framework, a question-and-answer site where you can ask for help and share what you’ve learned, and a thriving community of users and developers.

So, why should you learn ROS? The short answer is because it will save you time. ROS provides all the parts of a robot software system that you would otherwise have to write. It allows you to focus on the parts of the system that you care about, without worrying about the parts that you don’t care about.

Why should you read this book? There’s a lot of material on the ROS wiki, including detailed tutorials for many aspects of the framework. A thriving user community is ready to answer your questions on http://answers.ros.org. Why not just learn ROS from these resources? What we’ve tried to do in this book is to lay things out in a more ordered way and to give comprehensive examples of how you can use ROS to do interesting things with real and simulated robots. We’ve also tried to include tips and hints about how to structure your code, how to debug your code when it causes the robot to do something unexpected, and how to become part of the ROS community.

There’s a fair amount of complexity in ROS, especially if you’re not a seasoned programmer; distributed computation, multithreading, event-driven programming, and a host of other concepts lie at the heart of the system. If you’re not already familiar with at least some of these, ROS can have a daunting learning curve. This book is an attempt to flatten out that curve a bit by introducing you to the basics of ROS and giving you some practical examples of how to use it for real applications on real (and simulated) robots.

Who Should Read This Book?

If you want to make your robots do things in the real world, but don’t want to spend time reinventing the wheel, then this book is for you. ROS includes all of the computational infrastructure you’ll need to get your robots up and running and enough robotics algorithms to get them doing interesting things quickly.

If you’re interested in some particular aspect, like path planning, and want to investigate it in the context of a larger robot system, then this book is for you. We’ll show you how to get your robot doing interesting things using the infrastructure and algorithms in ROS and how to swap out some of the existing algorithms for your own.

If you want to get an introduction to the basic mechanisms of ROS and an overview of some of the things that are possible, but you’re a bit daunted by the scale of the information on the wiki, then this book is for you. We’ll give you a tour of the basic mechanisms and tools in ROS and concrete examples of complete systems that you can build on and adapt.

Who Should Not Read This Book?

Although we don’t want to exclude anyone from reading this book, it’s probably not the right resource for everyone. We make certain implicit assumptions about the robots that you will be using. They are probably running Linux, and have decent computational resources (at least equivalent to a laptop computer). They have sophisticated sensors, such as a Microsoft Kinect. They are ground-based, and probably can move about the world. If your robots don’t fall into at least some of these categories, the examples in this book might not be immediately relevant to you, although the material on the underlying mechanisms and tools should be.

This book is primarily about ROS, and not about robotics. While you will learn a bit about robotics here, we don’t go into great depth about many of the algorithms in ROS. If you’re looking for a broad introduction to robotics, then this book isn’t the one you’re looking for.

What You’ll Learn

This book is meant to be a broad introduction to programming robots with ROS. We’ll cover the important aspects of the basic mechanisms and tools that make up the core of ROS and show you how to use them to create software to control your robots. We’ll show you concrete examples of how you can use ROS to do some interesting things with your robots and give you advice on how to build on these examples to create your own systems.

In addition to the technical material, we’ll also show you how to navigate the larger ROS ecosystem, such as the wiki and the Q&A forum, and how to become a part of the global ROS community, sharing your code and newly found knowledge with other roboticists across the world.

Prerequisites

There are a few things that you need to know before you can really use the material in this book. Since ROS is a software framework, you really need to know how to program to properly understand it. Although it’s possible to program in ROS in a variety of languages, in this book we’re going to be using Python. If you don’t know Python, then a lot of the code here isn’t going to make much sense. Fortunately, Python is an easy language to learn! There are many excellent reference books and free websites available for learning Python, starting with the official Python website: http://python.org.

ROS works best in an Ubuntu Linux environment, and having some previous exposure to Linux will make your life a lot easier. We’ll try to introduce the important parts of Linux as we go, but having a basic understanding of the filesystem, the bash command shell, and at least one text editor will help you concentrate on the ROS-specific material.

A basic understanding of robotics, while not strictly necessary to learn ROS, will also be helpful. Knowing something about the underlying mathematics used by robotics, such as coordinate transforms and kinematic chains, will be useful for understanding some of the ROS mechanisms that we talk about. Again, we’ll try to give a brief introduction to some of this material, but if you’re not familiar with it, you might want to take a side track and dig into the robotics literature to fill in some background.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, directory and pathnames, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, namespaces, data types, environment variables, statements, and keywords. Also used for commands, command-line utilities, and ROS packages, nodes, topics, etc.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Note

This icon indicates a general note.

Tip

This icon signifies a tip or suggestion.

Warning

This icon indicates a warning or caution.

Using Code Examples

Supplemental material (code examples, exercises, etc.) is available for download: https://github.com/osrf/rosbook.

This book is here to help you get your job done. To that end, the examples in the above-linked repository are available under the Apache 2.0 License, which permits very broad reuse of the code.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Programming Robots with ROS by Morgan Quigley, Brian Gerkey, and William D. Smart (O’Reilly). Copyright 2015 Morgan Quigley, Brian Gerkey, and William D. Smart, 978-1-4493-2389-9.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online

Note

Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of plans and pricing for enterprise, government, education, and individuals.

Members have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/prog_robots_w_ros.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

First and foremost, we would like to thank our editors at O’Reilly, Mike Loukides, Meg Blanchette, and Dawn Schanafelt, all of whom showed great patience and uncommon restraint with us as we put this book together. We’d also like to thank everyone who gave us feedback on early drafts of the book, especially Andreas Bihlmaier, Jon Bohren, Zach Dodds, and Kat Scott. Their comments and suggestions made this a much better book.

Thanks, also, to everyone who’s helped us figure out how to make ROS do the right thing on our robots. Mike Ferguson helped with the Fetch examples. Steve Peters, Nate Koenig, and John Hsu from the Open Source Robotics Foundation (OSRF) answered some gnarly Gazebo simulation questions. William Woodall and Tully Foote (both from the OSRF) fielded a number of general ROS hacking questions.

Thanks as well to Dylan Jones, who caught a code bug at the last minute before the book went to press.

Finally, we’d like to thank all of the authors, maintainers, and users in the worldwide ROS community. If it wasn’t for them, ROS would not be what it is today, and we would not be writing this preface.

Get Programming Robots with ROS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.