Book Image

Hands-On ROS for Robotics Programming

By : Bernardo Ronquillo Japón
Book Image

Hands-On ROS for Robotics Programming

By: Bernardo Ronquillo Japón

Overview of this book

Connecting a physical robot to a robot simulation using the Robot Operating System (ROS) infrastructure is one of the most common challenges faced by ROS engineers. With this book, you'll learn how to simulate a robot in a virtual environment and achieve desired behavior in equivalent real-world scenarios. This book starts with an introduction to GoPiGo3 and the sensors and actuators with which it is equipped. You'll then work with GoPiGo3's digital twin by creating a 3D model from scratch and running a simulation in ROS using Gazebo. Next, the book will show you how to use GoPiGo3 to build and run an autonomous mobile robot that is aware of its surroundings. Finally, you'll find out how a robot can learn tasks that have not been programmed in the code but are acquired by observing its environment. You'll even cover topics such as deep learning and reinforcement learning. By the end of this robot programming book, you'll be well-versed with the basics of building specific-purpose applications in robotics and developing highly intelligent autonomous robots from scratch.
Table of Contents (19 chapters)
1
Section 1: Physical Robot Assembly and Testing
5
Section 2: Robot Simulation with Gazebo
8
Section 3: Autonomous Navigation Using SLAM
13
Section 4: Adaptive Robot Behavior Using Machine Learning

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.