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

Preface

Learning ROS and working with ROS robots such as Baxter and TurtleBot is the beginning of a big adventure. The features and benefits of ROS are substantial but the learning curve is steep. Through trial and error, we have foraged a path through many of the ROS applications. In this book, we hope to present to you the best of our knowledge of ROS and provide you with detailed step-by-step instructions for your journey. Our approach centers on using the ROS robots that are featured—TurtleBot, Baxter, Crazyflie, and Bebop as well as simulated robots—Turtlesim and Hector.

This book provides introductory information as well as advanced applications featuring these ROS robots. The chapters begin with the basics of setting up your computer and loading ROS and the packages for ROS robots and tools. Straightforward instructions are provided with troubleshooting steps when the desired results are not achieved. The building blocks of ROS are described first in the simulation, Turtlesim, and then on each of the featured robots. Starting with basic ROS commands, the ROS packages, nodes, topics, and messages are explored to gain an overall knowledge of these ROS robotic systems. Technical information on these example robots is provided to describe the robot's full capabilities.

ROS encompasses a full spectrum of software concepts, implementation, and tools that attempt to provide a homogeneous view of the complex systems and software integration required in robotics. Extensive libraries of sensor and actuator drivers and interfaces are already in place as well as the latest and most efficient algorithms. What ROS doesn't provide directly is imported from other prevailing open source projects such as OpenCV. ROS also possesses a spectrum of time-saving tools to control, monitor, and debug robot applications—rqt, rviz, Gazebo, dynamic reconfigure, and MoveIt to name a few.

In the pages that follow, each of these areas will be incrementally introduced to you as part of the robot examples. With TurtleBot, the subjects of navigation and mapping are explored. Using Baxter, joint control and path planning are described for your understanding. Simple Python scripts are included to provide examples of implementing ROS elements for many of these robots. These robots are all available in simulation to accomplish the exercises in this book. Furthermore, instructions are provided for you to build and control your own robot models in simulation.

The power of ROS, the variety of robots using ROS, and the diversity and support of the widespread ROS community make this adventure worthwhile. Extensive online tutorials, wiki instructions, forums, tips, and tricks are available for ROS. So dive into the pages of this book to begin your adventure with ROS robotics!

What this book covers

Chapter 1, Getting Started with ROS, explains the advantages of learning ROS and highlights the spectrum of robots currently using ROS. Instructions to install and launch ROS on a computer running a Ubuntu operating system are provided. An overview of the ROS architecture is given and its components are described. The Turtlesim simulation is introduced and used to provide a deeper understanding of how the components of ROS work and ROS commands.

Chapter 2, Creating Your First Two-Wheeled ROS Robot (in Simulation), introduces you to the ROS simulation environment of Gazebo. We will lead you through the steps to create your first robot simulation (a two-wheeled differential-drive base) and teach the structure of the Universal Robotic Description Format. The use of the ROS tools, rviz and Gazebo, are detailed to enable you to display your robot and interact with it.

Chapter 3, Driving Around with TurtleBot, introduces you to a real ROS robot, TurtleBot. This mobile base robot can be used in the simulation environment of Gazebo if you do not own one. ROS commands and Python scripts are used to control the TurtleBot through a variety of methods. The ROS tool, rqt, is introduced and subsets of its plugins are used to control TurtleBot and monitor its sensor data.

Chapter 4, Navigating the World with TurtleBot, explores visual sensors and the ability for a robot to map its environment. The 3D sensor options for TurtleBot's vision system are described and their setup and operation using ROS enables TurtleBot to navigate autonomously. The knowledge of Simultaneous Localization and Mapping techniques is applied in combination with TurtleBot's navigation stack to move about in the mapped environment.

Chapter 5, Creating Your First Robot Arm (in Simulation), provides a gentle introduction to the complexity of robotic arms. A simulated robot arm is designed and built using the macro language of Xacro. Controllers for the arm are created to operate the arm in Gazebo. Through developing the controllers for this arm, an insight into the mechanics and physics of a simple robot arm is offered.

Chapter 6, Wobbling Robot Arms Using Joint Control, takes a deeper look at the intricacies of controlling robotic arms. Our second ROS robot, the "state-of-the-art" Baxter robot, is introduced. Baxter has two 7 degree-of-freedom arms and a number of other sensors. Baxter Simulator is available as open source software to use for the instructions in this chapter. Examples are provided for the control of Baxter's arms using position, velocity, and torque modes with control for both forward and inverse kinematics. The ROS tool, MoveIt, is introduced for motion planning in simulation and execution on either a real or simulated Baxter.

Chapter 7, Making a Robot Fly, describes a small but growing area of ROS robotics—unmanned air vehicles. This chapter focuses on quadrotors, and an understanding of quadrotor hardware and flight control is provided. Instructions to download and control the simulated quadrotor Hector are supplied. With skills from flying a simulated quadrotor, you can move on to control a real Bitcraze Crazyflie or Parrot Bebop. Quadrotor control is via teleoperation or ROS topic/message commands.

Chapter 8, Controlling Your Robots with External Devices, presents a number of peripheral devices you can use to control a ROS robot. Joystick controllers, controller boards (Arduino and Raspberry Pi), and mobile devices all have ROS interfaces that can be integrated with your robot to provide external control.

Chapter 9, Flying a Mission with Crazyflie, incorporates many of the ROS components and concepts presented in this book into a challenging mission of autonomous flight. The mission involves the Crazyflie quadrotor flying to a "remote" target all mapped through a Kinect 3D sensor. This mission uses ROS message communication and co-ordinate transforms to employ the Kinect's view of the quadrotor and target to orchestrate the flight. Flight control software for the Crazyflie using PID control is described and provided as part of the mission software.

Chapter 10, Extending Your ROS Abilities, provides a few last ROS capabilities to stimulate the further learning of advanced ROS robotic applications. The ability to control a robot with voice commands, the ability for a robot to detect and recognize faces as well as the ability for a robot to speak are all presented.

What you need for this book

The format of this book is intended for you to follow along and perform the instructions as the information is provided. You will need a computer with Ubuntu 14.04 (Trusty Tahr) installed. Other Ubuntu versions and Linux distributions may work as well as Mac OS X, Android, and Windows but documentation for these versions will need to reference the ROS wiki (http://wiki.ros.org/Distributions).

The version of ROS that this book was written around is Indigo Igloo, which is the current release recommended for stability. Its end of life is targeted for April 2019. Other versions of ROS may be used but are untested.

All the software used in this book is open source and freely available for download and use. Instructions to download the software are found in the chapter where the software is introduced. In Chapter 1, Getting Started with ROS, instructions are given to download and set up the ROS software environment.

Our preferred method to download software is the use of Debian packages. Where no Debian packages exist, we refer to downloading the software from repositories such as GitHub.

Gazebo simulation performs intensive graphics processing and the use of a dedicated graphics card is advised but not required.

Peripheral devices such as 3D sensors, Xbox, or PS3 controllers, Arduino or Raspberry Pi controller boards, and Android mobile devices are optional equipment.

Who this book is for

If you are a robotics developer, whether a hobbyist, researcher, or professional, and are interested in learning about ROS through a hands-on approach, then this book is for you. You are encouraged to have a working knowledge of GNU/Linux systems and Python.

Conventions

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

Code words in text, directory names, filenames, file extensions, and pathnames are shown as follows: "The terminal commands rostopic and rosnode have a number of options".

A block of code is set as follows:

<?xml version='1.0'?>
<robot name="dd_robot">
  <!-- Base Link -->
  <link name="base_link">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
          <box size="0.5 0.5 0.25"/>
      </geometry>
    </visual>
  </link>
</robot>

To avoid repeating previous code blocks but provide placement of new code blocks, previous code left for reference is abbreviated and new code is highlighted as follows:

<?xml version='1.0'?>
<robot name="dd_robot">
  <!-- Base Link -->
  <link name="base_link">
  …
  </link>
  <!-- Right Wheel -->
  <link name="right_wheel">

Any command-line input is written as follows:

$ rosrun turtlesim turtlesim_node

Output from command is written as:

[ INFO] [1427212356.117628994]: Starting turtlesim with node name /turtlesim

New terms and important words are shown in bold.

Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "By clicking the Add button on the Displays panel."

URL references are shown as: http://www.ros.org/about-ros/

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 disliked. Reader feedback is important for us as it helps us develop titles that you will really find useful and enjoyable.

To send us general feedback, simply e-mail , and mention the book's title in 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 at 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 this book 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 download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/ROS-Robotics-By-Example. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with 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/ROSRoboticsByExample_ColorImages.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 could 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 to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.