Reader small image

You're reading from  Hands-On ROS for Robotics Programming

Product typeBook
Published inFeb 2020
PublisherPackt
ISBN-139781838551308
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Bernardo Ronquillo Japón
Bernardo Ronquillo Japón
author image
Bernardo Ronquillo Japón

Bernardo Ronquillo Japn is an Internet of Things (IoT) and robotics expert who has worked for top technology companies since 1995, including Instituto de Astrofsica de Canarias, Gran Telescopio Canarias, Altran, and Alestis Aerospace. Using his skills and experience, he founded The Robot Academy, where he develops open source hardware and software solutions for engineers and makers: Social Robot IO (2015), for the stimulation of children with autistic spectrum disorder; Robot JUS (2016), which helps engineers get deeper technical insights with the Robot Operating System (ROS) when using low-complexity hardware; and IIoT All-in-One (2018) as an industrial IoT training package for assisting companies in their digital transformation process.
Read more about Bernardo Ronquillo Japón

Right arrow

Preface

Why a new book about learning robotics with ROS? Well, programming is but a small part of what it takes to work with robots. If you want to become really good at robotics, you'll need skills in other areas as well: electromechanics, robot simulation, autonomous navigation, and machine learning/reinforcement learning. Each of these four topics is a building block that you will need to master on your path to acquiring full robotics skills. This book is divided into four parts, each one being devoted to each of these building blocks.

Part 1, Physical Robot Assembly and Testing, focuses on electromechanics and describes each hardware part of the robot, providing practical demonstrations of how to test every sensor and actuator that it is equipped with. This part of the book should provide you with a good understanding of how a mobile robot works.

Part 2, Robot Simulation with Gazebo, deals with robot simulation. It is here where we introduce ROS and develop a two-wheeled robot simulation that emulates both the physical aspects and the behavior of an actual robot. We will explore the concept of the digital twin, a virtual robot that is the twin of a physical one. This is a fundamental part of developing robotic applications, as it cuts the costs associated with testing real hardware. The digital twin allows us to speed up the development process and save testing with the physical robot for the advanced stages of development.

Part 3, Autonomous Navigation Using SLAM, is devoted to robot navigation, the most common task for mobile robots. State-of-the-art algorithms and techniques are explained in a practical manner, first in simulation and then with a physical robot.

Part 4, Adaptive Robot Behavior Using Machine Learning, focuses on machine learning and reinforcement learning, the most active fields in robot research and real-world robotic applications. By using this technology, a robot is able to transition from pure automatism – where every possible behavior or answer is coded – to being a flexible behavior machine, where the robot is capable of reacting in a smart way to environmental demands by learning from data. This data can be obtained from the robot's previous experience or gathered from the experience of similar robots.

To build a state-of-the-art robot application, you will first need to master and then combine these four building blocks. The result will be what is commonly known as a smart robot. This is your task – this is your challenge.

Who this book is for

If you are an engineer who wishes to build AI-powered robots powered using ROS, then this book is for you. Technicians and hobbyists who wish to develop their own ROS robotics projects will also find this book to be a useful resource.

What this book covers

Chapter 1, Assembling the Robot, provides the key concepts and the practical assembly guidelines about the mobile robot on which all the content in this book is based. With a very practical approach in mind, we dive deep into the characteristics of GoPiGo3 that makes it an ideal and cost-effective platform to learn robotics. By completing the GoPiGo3 assembly, you will have acquired the first manual skills necessary for manipulating typical components in robotics. To purchase GoPiGo3 kit, you can visit https://www.dexterindustries.com/gopigo3/ and apply the coupon code BRJAPON@PACKT to get a 10% discount.

Chapter 2, Unit Testing of GoPiGo3, provides you with a practical insight into how GoPiGo3 works. We do so by introducing the JupyterLab environment, a friendly interface that takes the structure of a notebook composed of human-readable paragraphs followed by Python code snippets. You will produce two versions of each test program: the JupyterLab notebook and the pure Python script. Using these programming tools, you will test each sensor/actuator individually and check that it's working properly, as well as gain an understanding of the technology behind.

Chapter 3, Getting Started with ROS, explains the basic concepts of ROS. It introduces you to the framework using easy-to-understand language, avoiding very technical descriptions. This is because our primary goal is to show you exactly what ROS is in a conceptual sense. It will be in the following chapters that deep technical descriptions are provided so that you are finally able to integrate ROS into your projects.

Chapter 4, Creating a Virtual Two-Wheeled ROS Robot, describes how to build a simple two-wheeled robot, a digital twin of GoPiGo3. The model is written in the Unified Robot Description Format (URDF) and the result is checked with RViz, an ROS tool that provides a configurable Graphical User Interface (GUI) to allow the user to display the specific information they are after. RViz may be used both for global robot visualization and for debugging specific features while building a model.

Chapter 5, Simulating Robot Behavior with Gazebo, teaches you how to plug the digital definition of your robot (the URDF file) into the simulation environment of Gazebo, which is powered with a physics engine able to emulate realistic behaviors. You will also develop your understanding of how to check and test a digital robot to ensure that its behavior represents well what should happen in the reality.

Chapter 6, Programming in ROS Commands and Tools, introduces you to command-line interaction with ROS and explains the types of ROS commands. We will explore the most frequently used communication patterns in ROS, including the publish-subscribe model. To deal with all of your ROS data, you will be introduced to rqt, which eases the process of developing and debugging applications. Also, ROS parameters are introduced to give you an overview of their power to manage robot configuration at a high level.

Chapter 7, Robot Control and Simulation, teaches you how to set up an ROS environment for a real robot, using GoPiGo3. We will start by looking at remote control using the keys of your laptop keyboard, then progress to the more technical method of using ROS Topics. This chapter will start you on your path from manual keyboard- and Topic-based control to internal programming logic, so that your robots can be capable of executing tasks autonomously.

Chapter 8, Virtual SLAM and Navigation Using Gazebo, explores the technique of Simultaneous Localization and Mapping (SLAM) using a practical approach and the digital twin of GoPiGo3. You will be taught why SLAM is required prior to proper navigation. The simulation will be run in Gazebo, the ROS-native simulation tool with a physics engine that offers realistic results.

Chapter 9, SLAM for Robot Navigation, shifts the focus to the real world with the physical GoPiGo3 robot. The chapter highlights the many details and practical questions that arise when you face a robotic task in a real environment. Simulation is good to start with, but the real proof that your robot performs as expected is gained by executing tasks in an actual scenario. This chapter is the starting point for you to get deeper into robot navigation and will be vital to your knowledge base if this is a field that you want to pursue.

Chapter 10, Applying Machine Learning in Robotics, intends to be a gentle introduction to the topic of machine learning in robotics, favoring intuition instead of complex mathematical formulations and putting the focus on understanding the common concepts used in the field. The practical example used in this chapter will involve the Pi camera of GoPiGo3 recognizing objects.

Chapter 11, Machine Learning with OpenAI Gym, gives you the theoretical background on reinforcement learning based on simple scenarios. This chapter allows you to better understand what happens under the hood in classical reinforcement training tasks. We will continue using practical examples to explore the concepts presented and will use the open source environment OpenAI Gym, which lets us easily test different algorithms from training agents, also driving robots in ROS.

Chapter 12, Achieve a Goal through Reinforcement Learning, goes a step further than computer vision for object recognition and shows that GoPiGo3 not only perceives things but can also take steps to achieve a goal. Our robot will have to decide what action to execute at every step of the simulation to achieve the goal. After executing each action, the robot will be provided with feedback on how good the decision it made was in the form of a reward. After some training, the incentive of the reward will enforce and reinforce good decision making.

To get the most out of this book

The book takes a practical approach to things and will encourage you to practice what you are learning with a physical robot. We choose GoPiGo3 (https://www.dexterindustries.com/gopigo3/) because of its modularity, moderate cost, and the fact that it's based on the Raspberry Pi. You can acquire a Raspberry Pi board from online stores worldwide. Before purchasing any component of the kit, we recommend that you first read Chapter 1, Assembling the Robot, to get basic information on all the components that you will need to purchase. To purchase GoPiGo3 kit, you can visit https://www.dexterindustries.com/gopigo3/ and apply the coupon code BRJAPON@PACKT to get a 10% discount.

Some knowledge of Python and/or C++ programming and familiarity with single-board computers such as the Raspberry Pi are required to get the most out of this book.

Finally, you will need a laptop with Ubuntu 16.04 Xenial Xerus or Ubuntu 18.04 Bionic Beaver. The code of the book has been tested using both operating systems. If you have to start from scratch, we recommend that you use Ubuntu 18.04 because it is the latest Long-term Support (LTS) version provided by Canonical and will be supported until April 2023.

All the installation instructions you'll need are given in the Technical requirements section at the beginning of each chapter.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

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/Hands-On-ROS-for-Robotics-Programming. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Code in Action

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "It seems that only the last line is executed, which is my_gopigo.left()."

A block of code is set as follows:

msg_range.header.frame_id = "distance"
msg_range.radiation_type = Range.INFRARED
msg_range.min_range = 0.02
msg_range.max_range = 3.0

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

std_msgs/Header header
uint8 radiation_type
float32 field_of_view
float32 min_range

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

$ cd./Chapter2_Unit_Tests/drivingAround
$ python <name_of_script.py>

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Check the vital signs by clicking Check Vital Signs."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On ROS for Robotics Programming
Published in: Feb 2020Publisher: PacktISBN-13: 9781838551308
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Bernardo Ronquillo Japón

Bernardo Ronquillo Japn is an Internet of Things (IoT) and robotics expert who has worked for top technology companies since 1995, including Instituto de Astrofsica de Canarias, Gran Telescopio Canarias, Altran, and Alestis Aerospace. Using his skills and experience, he founded The Robot Academy, where he develops open source hardware and software solutions for engineers and makers: Social Robot IO (2015), for the stimulation of children with autistic spectrum disorder; Robot JUS (2016), which helps engineers get deeper technical insights with the Robot Operating System (ROS) when using low-complexity hardware; and IIoT All-in-One (2018) as an industrial IoT training package for assisting companies in their digital transformation process.
Read more about Bernardo Ronquillo Japón