39,59 €
Robot Operating System is one of the most widely used software frameworks for robotic research and for companies to model, simulate, and prototype robots. Applying your knowledge of ROS to actual robotics is much more difficult than people realize, but this title will give you what you need to create your own robotics in no time!
This book is packed with over 14 ROS robotics projects that can be prototyped without requiring a lot of hardware. The book starts with an introduction of ROS and its installation procedure. After discussing the basics, you’ll be taken through great projects, such as building a self-driving car, an autonomous mobile robot, and image recognition using deep learning and ROS. You can find ROS robotics applications for beginner, intermediate, and expert levels inside!
This book will be the perfect companion for a robotics enthusiast who really wants to do something big in the field.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 360
Veröffentlichungsjahr: 2017
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: March 2017
Production reference: 1290317
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78355-471-3
www.packtpub.com
Author
Lentin Joseph
Copy Editor
Madhusudan Uchil
Reviewer
Ruixiang Du
Project Coordinator
Judie Jose
Commissioning Editor
Kartikey Pandey
Proofreader
Safis Editing
Acquisition Editor
Namrata Patil
Indexer
Pratik Shirodkar
Content Development Editor
Amedh Pohad
Graphics
Kirk D'Penha
Technical Editor
Prashant Chaudhari
Production Coordinator
Shantanu Zagade
Lentin Joseph is an author, entrepreneur, electronics engineer, robotics enthusiast, machine vision expert, embedded programmer, and the founder and CEO of Qbotics Labs (http://www.qboticslabs.com) from India.
He completed his bachelor's degree in electronics and communication engineering at the Federal Institute of Science and Technology (FISAT), Kerala. For his final year engineering project, he made a social robot that can interact with people. The project was a huge success and was mentioned in many forms of visual and print media. The main features of this robot were that it could communicate with people and reply intelligently and had some image processing capabilities such as face, motion, and color detection. The entire project was implemented using the Python programming language. His interest in robotics, image processing, and Python started with that project.
After his graduation, he worked for three years at a start-up company focusing on robotics and image processing. In the meantime, he learned to work with famous robotics software platforms such as Robot Operating System (ROS), V-REP, and Actin (a robotic simulation tool) and image processing libraries such as OpenCV, OpenNI, and PCL. He also knows about 3D robot design and embedded programming on Arduino and Tiva Launchpad.
After three years of work experience, he started a new company called Qbotics Labs, which mainly focuses on research into building some great products in domains such as robotics and machine vision. He maintains a personal website (http://www.lentinjoseph.com) and a technology blog called technolabsz (http://www.technolabsz.com). He publishes his works on his tech blog. He was also a speaker at PyCon2013, India, on the topic Learning Robotics Using Python.
Lentin is the author of the books Learning Robotics Using Python (http://learn-robotics.com) and Mastering ROS for Robotics Programming (http://mastering-ros.com), both by Packt Publishing. The first book was about building an autonomous mobile robot using ROS and OpenCV. This book was launched at ICRA 2015 and was featured on the ROS blog, Robohub, OpenCV, the Python website, and various other such forums. The second book is on mastering Robot Operating System, which was also launched at ICRA 2016, and is one of the bestselling books on ROS.
Lentin and his team were also winners of the HRATC 2016 challenge conducted as a part of ICRA 2016. He was also a finalist in the ICRA 2015 challenge, HRATC (http://www.icra2016.org/conference/challenges/).
I would like to express my gratitude to the readers of my previous two books on ROS (ROS). Actually, they encouraged me to write one more book on ROS itself.
I would like to thank the Packt Publishing team for giving support for publishing my books. It may have been a distant dream without you all.
I would especially like to thank Amedh Pohad and Namrata Patil of Packt Publishing, who guided me during the writing process. Thanks for all your suggestions.
A special thanks to Ruixiang Du and all other technical reviewers for improving the content and giving good suggestions. Without your suggestions, this book may not have become a good product.
The most important thing in my life is my family. Without their support, this would not have been possible. I would like to dedicate this book to my parents, who gave me the inspiration to write this book. This is my third book about ROS. Thanks for the constant support.
I would also like to mention my previous company, ASIMOV Robotics, who provided components for a few projects in this book. Thank you very much.
I thank all the readers who made by previous books successful. I hope you guys also like this book and make it successful.
Ruixiang Du is a PhD candidate in mechanical engineering at Worcester Polytechnic Institute (WPI). He currently works in the Systems and Robot Control laboratory with a research focus on the motion planning and control of autonomous mobile robots. He received a bachelor's degree in automation from North China Electric Power University in 2011 and a master's degree in robotics engineering from WPI in 2013.
Ruixiang has general interests in robotics and in real-time and embedded systems. He has worked on various robotic projects, with robot platforms ranging from medical robots and unmanned aerial/ground vehicles to humanoid robots. He was a member of Team WPI-CMU for the DARPA Robotics Challenge.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review at the website where you acquired this product.
If you'd like to join our team of regular reviewers, you can email us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
ROS Robotics Projects is a practical guide to learning ROS by making interesting projects using it. The book assumes that you have some knowledge of ROS. However, if you do not have any experience with ROS, you can still learn from this book. The first chapter is dedicated to absolute beginners. ROS is widely used in robotics companies, universities, and robot research labs for designing and programming robots. If you would like to work in the robotics software domain or if you want to have a career as a robotics software engineer, this book is perfect for you.
The basic aim of this book is to teach ROS through interactive projects. The projects that we are discussing here can also be reused in your academic or industrial projects. This book handles a wide variety of new technology that can be interfaced with ROS. For example, you will see how to build a self-driving car prototype, how to build a deep-learning application using ROS, and how to build a VR application in ROS. These are only a few highlighted topics; in addition, you will find some 15 projects and applications using ROS and its libraries.
You can work with any project after meeting its prerequisites. Most of the projects can be completed without many dependencies. We are using popular and available hardware components to build most of the projects. So this will help us create almost all of these projects without much difficulty.
The book starts by discussing the basics of ROS and its variety of applications. This chapter will definitely be a starting point for absolute beginners. After this chapter, we will explore a wide variety of ROS projects.
Let’s learn and make cool projects with ROS!
Chapter 1, Getting Started with ROS Robotics Application Development, is for absolute beginners to ROS. No need to worry if you don’t have experience in ROS; this chapter will help you get an idea of the ROS software framework and its concepts.
Chapter 2, Face Detection and Tracking Using ROS, OpenCV and Dynamixel Servos, takes you through a cool project that you can make with ROS and the OpenCV library. This project basically creates a face tracker application in which your face will be tracked in such a way that the camera will always point to your face. We will use intelligent servos such as Dynamixel to rotate the robot on its axis.
Chapter 3, Building a Siri-Like Chatbot in ROS, is for those of you who want to make your robot interactive and intelligent without much hassle. This project creates a chatterbot in ROS that you can communicate with using text or speech. This project will be useful if you're going to create social or service robots.
Chapter 4, Controlling Embedded Boards Using ROS, helps you build a robot using Arduino, an embedded compatible board, Raspberry Pi, or Odroid and an interface to ROS. In this chapter, you will see a wide variety of embedded boards and interfacing projects made with them.
Chapter 5, Teleoperate a Robot Using Hand Gestures, will teach you how to build a gesture-control device using Arduino and IMU. The gestures are translated into motion commands by ROS nodes.
Chapter 6, Object Detection and Recognition, has interesting project for detecting objects. You will learn both 2D and 3D object recognition using powerful ROS packages.
Chapter 7, Deep Learning Using ROS and TensorFlow, is a project made using a trending technology in robotics. Using the TensorFlow library and ROS, we can implement interesting deep-learning applications. You can implement image recognition using deep learning, and an application using SVM can be found in this chapter.
Chapter 8, ROS on MATLAB and Android, is intended for building robot applications using ROS, MATLAB, and Android.
Chapter 9, Building an Autonomous Mobile Robot, is about creating an autonomous mobile robot with the help of ROS. You can see how to use packages such as navigation, gmapping, and AMCL to make a mobile robot autonomous.
Chapter 10, Creating a Self-driving Car Using ROS, is one of the more interesting projects in this book. In this chapter, we will build a simulation of self-driving car using ROS and Gazebo.
Chapter 11, Teleoperating Robot Using VR Headset and Leap Motion, shows you how to control a robot's actions using a VR headset and Leap Motion sensor. You can play around with virtual reality, a trending technology these days.
Chapter 12, Controlling Your Robots over the Web, we will see how to build interactive web applications using rosbridge in ROS.
You should have a powerful PC running a Linux distribution, preferably Ubuntu 16.04 LTS.
You can use a laptop or desktop with a graphics card, and RAM of 4-8 GB is preferred. This is actually for running high-end simulations in Gazebo, as well as for processing point clouds and computer vision.
You should have the sensors, actuators, and I/O boards mentioned in the book and should be able to connect them all to your PC.
You also need Git installed to clone the package files.
If you are a Windows user, then it will be good to download VirtualBox and set up Ubuntu on it. You can have issues when you try to interface real hardware to ROS when working with VirtualBox. So, it is best if you can work from a real Linux system.
If you are a robotics enthusiast or researcher who wants to learn more about building robot applications using ROS, this book is for you. In order to learn from this book, you should have a basic knowledge of ROS, GNU/Linux, and C++ programming concepts. The book is also good for programmers who want to explore the advanced features of ROS.
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 get the most out of. To send us general feedback, simply e-mail [email protected], 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.
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.
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:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/ROS-Robotics-Projects. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
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 https://www.packtpub.com/sites/default/files/downloads/ROSRoboticsProjects_ColorImages.pdf.
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 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 [email protected] with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
Robotics is one of the upcoming technologies that can change the world. Robots can replace people in many ways, and we are all afraid of them stealing our jobs. One thing is for sure: robotics will be one of the influential technologies in the future. When a new technology gains momentum, the opportunities in that field also increase. This means that robotics and automation can generate lot of job opportunities in the future.
One of the main areas in robotics that can provide mass job opportunities is robotics software development. As we all know, software gives life to a robot or any machine. We can expand a robot's capabilities through software. If a robot exists, its capabilities such as control, sensing, and intelligence are realized using software.
Robotics software involves a combination of related technologies, such as computer vision, artificial intelligence, and control theory. In short, developing software for a robot is not a simple task; it may require expertise in many fields.
If you're looking for mobile application development in iOS or Android, there is a software development kit (SDK) available to build applications in it, but what about robots? Is there any generic software framework available? Yes. One of the more popular robotics software frameworks is called Robot Operating System (ROS).
In this chapter, we will take a look at an abstract concept of ROS and how to install it. The entire book is dedicated to ROS projects, so this chapter will be a kick-start guide for those projects.
The following topics are going to be covered in this chapter:
So let's get started discussing ROS.
ROS is an open source, flexible software framework for programming robots. ROS provides a hardware abstraction layer, in which developers can build robotics applications without worrying about the underlying hardware. ROS also provides different software tools to visualize and debug robot data. The core of the ROS framework is a message-passing middleware in which processes can communicate and exchange data with each other even when running from different machines. ROS message passing can be synchronous or asynchronous.
Software in ROS is organized as packages, and it offers good modularity and reusability. Using the ROS message-passing middleware and hardware abstraction layer, developers can create tons of robotic capabilities, such as mapping and navigation (in mobile robots). Almost all capabilities in ROS will be robot agnostic so that all kinds of robots can use it. New robots can directly use this capability package without modifying any code inside the package.
ROS has widespread collaborations in universities, and lots of developers contribute to it. We can say that ROS is a community-driven project supported by developers worldwide. The active developer ecosystem distinguishes ROS from other robotic frameworks.
In short, ROS is the combination of Plumbing (or communication), Tools, Capabilities and Ecosystem. These capabilities are demonstrated in the following figure:
Figure 1: The ROS equation
The ROS project was started in 2007 in Stanford University under the name Switchyard. Later on, in 2008, the development was undertaken by a robotic research start-up called Willow Garage. The major development in ROS happened in Willow Garage. In 2013, the Willow Garage researchers formed the Open Source Robotics Foundation (OSRF). ROS is actively maintained by OSRF now.
Here are links to their websites:
The ROS distributions are very similar to Linux distributions, that is, a versioned set of ROS packages. Each distribution maintains a stable set of core packages up to the end of life (EOL) of the distribution.
The ROS distributions are fully compatible with Ubuntu, and most of the ROS distributions are planned according to the respective Ubuntu versions.
Given here are some of latest ROS distributions recommended for use from the ROS website (http://wiki.ros.org/Distributions):
Figure 2: Latest ROS distributions
The latest ROS distribution is Kinect Kame. We will get support for this distribution up to May 2021. One of the problems with this latest ROS distribution is that most of the packages will not be available on it because it will take time to migrate them from the previous distribution. If you are looking for a stable distribution, you can go for ROS Indigo Igloo, because the distribution started in 2015, and most of the packages are available on this distribution. The ROS Jade Turtle distribution will stop being supported on May 2017, so I do not recommend you use it.
The main operating system ROS is tuned for is Ubuntu. ROS distributions are planned according to Ubuntu releases. Other than Ubuntu, it is partially supported by Ubuntu ARM, Debian, Gentoo, Mac OS X, Arch Linux, Android, Windows, and Open Embedded:
Figure 3: OSes supporting ROS
This table shows new ROS distributions and the specific versions of the supporting OSes:
ROS distribution
Supporting OSes
Kinetic Kame (LTS)
Ubuntu 16.04 (LTS) and 15.10, Debian 8, OS X (Homebrew), Gentoo, and Ubuntu ARM
Jade Turtle
Ubuntu 15.04, 14.10, and 14.04, Ubuntu ARM, OS X (Homebrew), Gentoo, Arch Linux, Android NDK, and Debian 8
Indigo Igloo (LTS)
Ubuntu 14.04 (LTS) and 13.10, Ubuntu ARM, OS X (Homebrew), Gentoo, Arch Linux, Android NDK, and Debian 7
ROS Indigo and Kinetic are long-term support (LTS) distributions, coming with the LTS version of Ubuntu. The advantage of using LTS distribution is that we will get maximum lifespan and support.
The ROS framework is one of the successful robotics frameworks, and universities around the globe contribute to it. Because of the active ecosystem and open source nature, ROS is being used in a majority of robots and is compatible with major robotic hardware and software. Here are some of the famous robots completely running on ROS:
Figure 4: Popular robots supported by ROS
The names of the robots listed in the images are Pepper (a), REEM-C (b), TurtleBot (c), Robonaut (d), Universal Robots (e).
The robots supported by ROS are listed at the following link:
http://wiki.ros.org/Robots.
The following are links to get ROS packages of robots from:
Some popular sensors supporting ROS are as follows:
Figure 5: Popular robot sensors supported in ROS
The names of the sensors listed in the image are Velodyne (a), ZED Camera (b), Teraranger (c), Xsens (d), Hokuyo Laser range finder (e), and Intel RealSense (f).
The list of sensors supported by ROS is available at the following link:
http://wiki.ros.org/Sensors
These are the links to the ROS wiki pages of these sensors:
The main intention behind building the ROS framework is to become a generic software framework for robots. Even though there was robotics research happening before ROS, most of the software was exclusive to their own robots. Their software may be open source, but it is very difficult to reuse.
Compared to existing robotic frameworks, ROS is outperforming in the following aspects:
Given here are the URLs of libraries and simulators integrated with ROS:
Let's go through some of the basic concepts of ROS; they can help you get started with ROS projects.
Understanding the basic working of ROS and its terminology can help you understand existing ROS applications and build your own. This section will teach you important concepts that we are going to use in the upcoming chapters. If you find a topic missed in this chapter, it will be covered in a corresponding later chapter.
There are three different concepts in ROS. Let's take a look at them.
The filesystem level explains how ROS files are organized on the hard disk:
Figure 6: The ROS filesystem level
As you can see from the figure, the filesystem in ROS can be categorized mainly as metapackages, packages, package manifest, messages, services, codes and miscellaneous files. The following is a short description of each component:
The ROS computation graph is the peer-to-peer network of the ROS process, and it processes the data together. The ROS computation graph concepts are nodes, topics, messages, master, parameter server, services, and bags:
Figure 7: The ROS computational graph concept diagram
The preceding figure shows the various concepts in the ROS computational graph. Here is a short description of each concept:
The community level comprises the ROS resources for sharing software and knowledge:
Figure 8: ROS community level diagram
Here is a brief description of each section:
Let's see how two nodes communicate with each other using ROS topics. The following diagram shows how it happens:
Figure 9: Communication between ROS nodes using topics
As you can see, there are two nodes, named talker and listener. The talker node publishes a string message called Hello World into a topic called /talker, and the listener node is subscribed to this topic. Let's see what happens at each stage, marked (1), (2), and (3):
