Programming Robots with ROS
Morgan Quigley
Brian Gerkey
William D. Smart
Beijing Cambridge Farnham Kln Sebastopol Tokyo
Preface
ROS, the Robot Operating System, is an open-source framework forgetting robots to do things. ROS is meant to serve as acommon software platform for (some subset of) the people who werebuilding and using robots. This common software letspeople share code and ideas more readily and, perhaps moreimportantly, means that you do not have to spend years writingsoftware infrastructure before your robots start moving!
ROS has been remarkable successful. At the time of writing, in theofficial distribution of ROS there are XXX software packages, writtenand maintained by XXX people. XXX commercially-available robots aresupported, and we can find at least XXX academic papers that mentionROS. We no longer have to write everything from scratch, especiallyif were working with one of the many robots that support ROS, and canspend more time thinging about robotics , rather than bit-fiddlingand device drivers.
ROS consists of a number of parts:
- 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 growning number of commercially-available robot systems.
- 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 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.
- 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.
- 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 are one of the things that make ROS as powerful as it is.
- 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 youve learned, and a thriving community of users and developers.
GOT TO HERE
So, why should you learn ROS? The short answer is because it willsave you time. ROS provides all the parts of a robot software systemthat you would otherwise have to write. It allows you to focus on theparts of the system that you care about, without worry about the partsthat you dont care about.
Why should you read this book? Theres a lot of material on the ROSwiki, including detailed tutorials for many aspects of the framework.A thriving user community is ready to answer your questions onhttp://answers.ros.org. Why not just learn ROS from these resources?What weve tried to do in this book is to lay things out in a moreordered way, and to give comprehensive examples of how you can use ROSto do interesting things with real and simulated robots. Weve alsotried to include tips and hints about how to structure your code, howto debug your code when it causes the robot to do somethingunexpected, and how to become part of the ROS community.
Theres a fair amount of complexity in ROS, especially if youre not aseasoned programmer; distributed computation, multi-threading,even-driven programming, and a host of other concepts lie at the heartof the system. If youre not already familiar with at least some ofthese, ROS can have a daunting learning curve. This book is anattempt to flatted out that curve a bit by introducing you to thebasics of ROS, and giving you some practical examples of how to use itfor 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 dontwant to spend time reinventing the wheel, then this book is for you.ROS includes all of the computational infrastructure youll need toget your robots up and running, and enough robotics algorithms to getthem doing interesting things quickly.
If youre interested some aspect, like path planning, and want toinvestigate it in the context of a larger robot system, then this bookis for you. Well show you how to get your robot doing interestingthings using the infrastructure and algorithms in ROS, and how to swapout some of the existing algorithms for your own.
If you want to get an introduction to the basic mechanisms of ROS andan overview of some of the things that are possible, but youre a bitdaunted by the scale of the information on the wiki, then this book isfor you. Well give you a tour of the basic mechanisms and tools inROS and concrete examples of complete systems that you can build onand adapt.
Who Should Not Read This Book?
Although we dont want to exclude anyone from reading this book, itsprobably not the right resource for everyone. We make certainimplicit assumptions about the robots that you will be using. Theyare probably running Linux, and have decent computational resources(at least equivalent to a laptop computer). They have sophisticatedsensors, such as a Microsoft Kinect. They are ground-based, andprobably can move about the world. If your robots dont fall into atleast some of these categories, the examples in this book might not beimmediately relevant to you, although the material on the underlyingmechanisms and tools should be.
This book is primarily about ROS, and not about robotics. While youwill learn a bit about robotics here, we dont go into great depthabout many of the algorithms in ROS. If youre looking for a broadintroduction to robotics, then this book isnt the one youre lookingfor.
What Youll Learn
This book is meant to be a broad introduction to programming robotswith ROS. Well cover the important aspects of the basic mechanismsand tools that comprise the core of ROS, and show you how to use themto create software to control your robots. Well show you concreteexamples of how you can use ROS to do some interesting things withyour robots, and give you advice on how to build on these examples tocreate your own systems.
In addition to the technical material, well also show you how tonavigate the larger ROS ecosystem, such as the wiki andhttp:answers.ros.org, and how to become a part of the global ROScommunity, sharing your code and newly-found knowledge with otherroboticists across the world.
Prerequisites
There are a few things that you need to know before you can really usethe material in this book. Since ROS is a software framework, youreally need to know how to program to properly understand it.Although its possible to program in ROS in a variety of languages, inthis book were going to be using Python. If you dont know Python,then a lot of the code here isnt going to make much sense.
ROS works best in an Ubuntu Linux environment, and having someprevious exposure to Linux will make your life a lot easier. Welltry to introduce the important parts of Linux as we go, but having abasic understanding of the filesystem, the bash
command shell, andat least one text editor will help you concentrate on the ROS-specificmaterial.