Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On ROS for Robotics Programming

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

Product type Book
Published in Feb 2020
Publisher Packt
ISBN-13 9781838551308
Pages 432 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Bernardo Ronquillo Japón Bernardo Ronquillo Japón
Profile icon Bernardo Ronquillo Japón

Table of Contents (19) Chapters

Preface Section 1: Physical Robot Assembly and Testing
Assembling the Robot Unit Testing of GoPiGo3 Getting Started with ROS Section 2: Robot Simulation with Gazebo
Creating the Virtual Two-Wheeled ROS Robot Simulating Robot Behavior with Gazebo Section 3: Autonomous Navigation Using SLAM
Programming in ROS - Commands and Tools Robot Control and Simulation Virtual SLAM and Navigation Using Gazebo SLAM for Robot Navigation Section 4: Adaptive Robot Behavior Using Machine Learning
Applying Machine Learning in Robotics Machine Learning with OpenAI Gym Achieve a Goal through Reinforcement Learning Assessment Other Books You May Enjoy

Applying Machine Learning in Robotics

This chapter provides a hands-on introduction to machine learning (ML) in robotics. Although we assume that you have not yet worked in such a field, it will be helpful to have some background in statistics and data analytics. In any case, this chapter intends to be a gentle introduction to the topic, favoring intuition instead of complex mathematical formulations, and putting the focus on understanding the common concepts used in the field of ML.

Throughout this chapter, we will devote the discussion to such concepts by providing specific examples of robots. This is somewhat original because most references and books on ML give examples oriented to data science. Hence, as you become more familiar with robotics, it should be easier for you to understand the concepts this way.

With the explanations about deep learning, you will understand how...

Technical requirements

For the examples in this chapter, we will use TensorFlow (https://www.tensorflow.org/), the ML framework open-sourced by Google in 2015, which has become the big brother in the data science community because of all of the people involved as active developers or end users.

The main TensorFlow API is developed in Python and is the one we are going to use. To install it, we need to have the well-known pip Python package manager in our system. Even though it comes bundled with the Ubuntu OS, we provide the instructions for installing it. Later, we will cover the TensorFlow installation process.

Let's first provide the path for the code of this chapter, and then describe the step-by-step procedure to configure your laptop with TensorFlow.

In this chapter, we will make use of the code located in the Chapter10_Deep_Learning_ folder at https://github.com/PacktPublishing...

Setting up the system for TensorFlow

First, we will set up pip, the Python package manager and afterward the framework for performing ML, that is, TensorFlow.

Installing pip

Ubuntu distributions typically ship with pip preinstalled. Unless a Python library requests you to upgrade, you can stay with the same version. In any case, we recommend working with the latest one, as explained in the following.

Installing the latest version

This section applies to the case in which you need to install pip or upgrade it:

  1. First, remove the previous version if there is one:
$ sudo...

ML comes to robotics

ML has its roots in statistical science. Remember when you have a cloud of points on an x-y frame and try to find the straight line that best fits all of them at the same time? This is what we call a linear regression and can be solved with a simple analytical formula. Regression is the first algorithm that you typically study when getting started with ML.

To acquire perspective, be aware that, before 1980, artificial intelligence and ML were part of the same corpora of knowledge. Then, artificial intelligence researchers focused their efforts on using logical, knowledge-based approaches, and ML kept the algorithmic approach, regression being the most basic and having neural network-based algorithms as its main bundle. Hence, this fact favored that ML evolved as a separated discipline.

Following path of the traditional research in neural networks in the &apos...

From ML to deep learning

In this section, you will understand what deep learning is and how it relates to ML. And the most straightforward way to get this insight is by giving a quick overview of the most commonly used algorithms. Then, from that perspective, you could appreciate why deep learning is the most active area of research nowadays.

ML algorithms

As pointed out in the preceding diagram and explanations, the algorithm is the central part of ML problem-solving. A data scientist has also to select which one to apply depending on the kind of problem they are facing. So, let's have a quick overview of the most commonly used algorithms.

...

A methodology to programmatically apply ML in robotics

A specific aspect of ML is that robot responses have to happen in real time, without delays, so that the actions taken are effective. For example, if it finds an obstacle crossing the path it is following, we expect that it avoids it. To do so, obstacle identification has to occur as it appears in the robot's field of view. Hence, the subsequent action of avoiding the obstacle has to be taken immediately to avoid a crash.

We will support our methodology description with an end-to-end example that covers all that GoPiGo3 can do up to this point. Then, with this example, we expect that GoPiGo3 can carry a load on top of its chassis from its current location to a target location (a common case in garbage collector robots).

A...

Deep learning applied to robotics – computer vision

The practical part of this chapter consists of operationally implementing the ML node described earlier. What we represented there as a black box is developed now as a ROS package that you may integrate with the functionalities you discovered in previous chapters:

  • The remote control in Chapter 7, Robot Control and Simulation, for both the virtual robot in Gazebo and the physical GoPiGo3
  • Robot navigation for a virtual robot in Chapter 8, Virtual SLAM and Navigation Using Gazebo, and the physical GoPiGo3 in Chapter 9, SLAM for Robot Navigation

So, we divide this section into two parts:

  • The first section, Object recognition in Gazebo, provides you with the tools to integrate the ML node for image recognition in Gazebo so that, after finishing the practice, you may let your creativity fly to combine object recognition with...

Summary

This chapter provided a quick introduction to ML in robotics. We expect you to have acquired insight into what ML and deep learning are, qualitatively understood how a neural network processes images to recognize objects, and can operationally implement the algorithm in a simulated and/or physical robot.

ML is a very wide field and you should not expect nor really need to get an expert in the field. What you need to assimilate is the knowledge to integrate deep learning capabilities in your robots.

As you have seen in the practical case, we have used a pretrained model that covers common objects. Then, we have simply used this model and have not needed additional training. There are plenty of trained models on the web shared by data science companies and open source developers. You should spend time looking for these models, and only go to train your own models when the...

Questions

  1. What is the task for solving ML that requires more experience and insight from the data scientist?

A) The algorithm selection
B) The feature selection
C) The model

  1. What is the relationship between ML and deep learning?

A) ML covers many algorithms and deep learning only algorithms to find deep features.
B) Deep learning is a subset of ML.
C) Deep learning deals with all of the ML algorithms except neural networks.

  1. How should you integrate an ML task with a ROS application?

A) You should train the model outside and then provide ROS with a file of results.
B) You have the choice of using publish/subscribe, a ROS service, or an action server.
C) You have to use the specific communication protocol of the ML model.

  1. What is the main difference between the publish/subscribe mechanism and the ROS service mechanism?

A) ROS service is synchronous while publish/subscribe is...

Further reading

To delve deeper into the concepts explained in this chapter, you can check out the following references:

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 2020 Publisher: Packt ISBN-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.
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}