Book Image

ROS Robotics Projects - Second Edition

By : Ramkumar Gandhinathan
Book Image

ROS Robotics Projects - Second Edition

By: Ramkumar Gandhinathan

Overview of this book

Nowadays, heavy industrial robots placed in workcells are being replaced by new age robots called cobots, which don't need workcells. They are used in manufacturing, retail, banks, energy, and healthcare, among other domains. One of the major reasons for this rapid growth in the robotics market is the introduction of an open source robotics framework called the Robot Operating System (ROS). This book covers projects in the latest ROS distribution, ROS Melodic Morenia with Ubuntu Bionic (18.04). Starting with the fundamentals, this updated edition of ROS Robotics Projects introduces you to ROS-2 and helps you understand how it is different from ROS-1. You'll be able to model and build an industrial mobile manipulator in ROS and simulate it in Gazebo 9. You'll then gain insights into handling complex robot applications using state machines and working with multiple robots at a time. This ROS book also introduces you to new and popular hardware such as Nvidia's Jetson Nano, Asus Tinker Board, and Beaglebone Black, and allows you to explore interfacing with ROS. You'll learn as you build interesting ROS projects such as self-driving cars, making use of deep learning, reinforcement learning, and other key AI concepts. By the end of the book, you'll have gained the confidence to build interesting and intricate projects with ROS.
Table of Contents (14 chapters)

Getting started with 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 they're 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 the 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. This 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 diagram:

The ROS equation (source: ros.org. licensed under Creative Commons CC-BY-3.0: https://creativecommons.org/licenses/by/3.0/us/legalcode)

The ROS project was started in 2007 at Stanford University under the name Switchyard. Later on, in 2008, the development was undertaken by a robotic research startup 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. Now, let's look at a few ROS distributions.

Here are links to their websites: Willow Garage: http://www.willowgarage.com/
OSRF: http://www.osrfoundation.org/.

ROS distributions

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 their respective Ubuntu versions.

The following are some of the latest ROS distributions (at the time of writing) that are recommended for use from the ROS website (http://wiki.ros.org/Distributions):

Latest ROS distributions (source: ros.org. licensed under Creative Commons CC-BY-3.0: https://creativecommons.org/licenses/by/3.0/us/legalcode)

The latest ROS distribution is Melodic Morenia. We will get support for this distribution up until May 2023. 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 Kinetic Kame because the distribution started in 2016, and most of the packages are available on this distribution. The ROS Lunar Loggerhead distribution will stop being supported in May 2019, so I do not recommend that you use it.

Supported OSes

The main OS 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, macOS, Arch Linux, Android, Windows, and OpenEmbedded.

This table shows new ROS distributions and the specific versions of the supporting OSes:

ROS distribution

Supporting OSes

Melodic Morenia (LTS)

Ubuntu 18.04 (LTS) and 17.10, Debian 8, macOS (Homebrew), Gentoo, and Ubuntu ARM

Kinetic Kame (LTS)

Ubuntu 16.04 (LTS) and 15.10, Debian 8, macOS (Homebrew), Gentoo, and Ubuntu ARM

Jade Turtle

Ubuntu 15.04, 14.10, and 14.04, Ubuntu ARM, macOS (Homebrew), Gentoo, Arch Linux, Android NDK, and Debian 8

Indigo Igloo (LTS)

Ubuntu 14.04 (LTS) and 13.10, Ubuntu ARM, macOS (Homebrew), Gentoo, Arch Linux, Android NDK, and Debian 7

ROS Melodic and Kinetic are Long-Term Support (LTS) distributions that come with the LTS version of Ubuntu. The advantage of using LTS distribution is that we will get maximum lifespan and support.

We will look at a few robots and sensors that are supported by ROS in the next section.

Robots and sensors supported by ROS

The ROS framework is one of the most successful robotics frameworks, and universities around the globe contribute to it. Because of its 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 most famous robots completely running on ROS:

Popular robots supported by ROS (Source: ros.org. Licensed under Creative Commons CC-BY-3.0: https://creativecommons.org/licenses/by/3.0/us/legalcode)

The names of the robots listed in preceding images are Pepper (a), REEM-C (b), Turtlebot (c), Robonaut (d), and Universal Robots (e).

The robots supported by ROS are listed at the following link: http://wiki.ros.org/Robots.

The following are the links where you can get the ROS packages of these robots:

Some popular sensors that support ROS are as follows:

Popular robot sensors supported in ROS

The names of the sensors in the preceding 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.

The following are the links to the ROS wiki pages of these sensors:

Now, let's look at the advantages of using ROS.

Why use ROS?

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:

  • Collaborative development: As we've already discussed, ROS is open source and free to use for industries and research. Developers can expand the functionalities of ROS by adding packages. Almost all ROS packages work on a hardware abstraction layer, so it can be reused easily for other robots. So, if one university is good in mobile navigation and another is good in robotic manipulators, they can contribute that to the ROS community and other developers can reuse their packages and build new applications.
  • Language support: The ROS communication framework can be easily implemented in any modern programming language. It already supports popular languages such as C++, Python, and Lisp, and it has experimental libraries for Java and Lua.
  • Library integration: ROS has an interface to many third-party robotics libraries, such as Open Source Computer Vision (OpenCV), Point Cloud Library (PCL), Open-NI, Open-Rave, and Orocos. Developers can work with any of these libraries without much hassle.
  • Simulator integration: ROS also has ties to open source simulators such as Gazebo and has a good interface with proprietary simulators such as Webots and V-REP.
  • Code testing: ROS offers an inbuilt testing framework called rostest to check code quality and bugs.
  • Scalability: The ROS framework is designed to be scalable. We can perform heavy computation tasks with robots using ROS, which can either be placed on the cloud or on heterogeneous clusters.
  • Customizability: As we have already discussed, ROS is completely open source and free, so we can customize this framework as per the robot's requirements. If we only want to work with the ROS messaging platform, we can remove all of the other components and use only that. We can even customize ROS for a specific robot for better performance.
  • Community: ROS is a community-driven project, and it is mainly led by OSRF. The large community support is a great plus for ROS and means we can easily start robotics application development.

The following are the URLs of libraries and simulators that can be integrated with ROS:

Let's go through some of the basic concepts of ROS; these can help you get started with ROS projects.