Reader small image

You're reading from  Mastering ROS for Robotics Programming, Third edition - Third Edition

Product typeBook
Published inOct 2021
PublisherPackt
ISBN-139781801071024
Edition3rd Edition
Concepts
Right arrow
Authors (2):
Lentin Joseph
Lentin Joseph
author image
Lentin Joseph

Lentin Joseph is an author and robotics entrepreneur from India. He runs a robotics software company called Qbotics Labs in India. He has 7 years of experience in the robotics domain primarily in ROS, OpenCV, and PCL. He has authored four books in ROS, namely, Learning Robotics using Python, Mastering ROS for Robotics Programming, ROS Robotics Projects, and Robot Operating System for Absolute Beginners. He is currently pursuing his master's in Robotics from India and is also doing research at Robotics Institute, CMU, USA.
Read more about Lentin Joseph

Jonathan Cacace
Jonathan Cacace
author image
Jonathan Cacace

Jonathan Cacace was born in Naples, Italy, on December 13, 1987. He received his Master's degree in computer science, and a Ph.D. degree in Information and Automation Engineering, from the University of Naples Federico II. Currently, he is an Assistant Professor at the University of Naples Federico II. He is also a member of PRISMA Lab where he is involved in different research projects focused on industrial and service robotics in which he has developed several ROS-based applications integrating robot perception and control.
Read more about Jonathan Cacace

View More author details
Right arrow

Chapter 6: Using the ROS MoveIt! and Navigation Stack

In the previous chapters, we have been discussing the design and simulation of a robotic arm and a mobile robot. We controlled each joint of the robotic arm in Gazebo using the Robot Operating System (ROS) controller and moved the mobile robot inside Gazebo using the teleop node.

In this chapter, we are going to address the motion-planning problem. Moving a robot by directly controlling its joints manually might be a difficult task, especially if we want to add position or velocity constraints to the robot's motion. Similarly, driving a mobile robot and avoiding obstacles requires the planning of a path. For this reason, we will solve these problems using the ROS MoveIt! and Navigation stack.

MoveIt! represents a set of packages and tools for doing mobile manipulation in ROS. The official web page (http://moveit.ros.org/) contains documentation, a list of robots using MoveIt!, and various examples to demonstrate pick...

Technical requirements

To follow along with this chapter, you need a standard computer running Ubuntu 20.04 as the operating system, along with ROS Noetic. Additional dependencies will be installed during this chapter.

The reference code for this chapter can be downloaded from the following Git repository: https://github.com/PacktPublishing/Mastering-ROS-for-Robotics-Programming-Third-edition/tree/main/Chapter6

You can view this chapter's code in action here: https://bit.ly/2UxKNN2.

The MoveIt! architecture

Before using MoveIt! in our ROS system, you have to install it. The installation procedure is very simple and is just a single command. Using the following commands, we install the MoveIt! core, a set of plugins and planners for ROS Noetic:

sudo apt-get install ros-noetic-moveit ros-noetic-moveit-plugins ros-noetic-moveit-planners

Let's start with MoveIt! by discussing its architecture. Understanding the architecture of MoveIt! helps to program and interface the robot with MoveIt!. We will quickly go through the architecture and the important concepts of MoveIt!, and start interfacing with and programming our robots.

Here is an overview of the MoveIt! architecture:

Figure 6.1 – MoveIt! architecture diagram

This diagram is also included in their official web page, at http://moveit.ros.org/documentation/concepts.

The move_group node

We can say that move_group is the heart of MoveIt!, as this node acts as an...

Generating a MoveIt! configuration package using the Setup Assistant tool

The MoveIt! Setup Assistant tool is a GUI for configuring any robot to MoveIt!. This tool basically generates SRDF, configuration files, launch files, and scripts generated from the robot URDF model, which is required to configure the move_group node.

The SRDF file contains details about the arm joints, end effector joints, virtual joints, and the collision-link pairs that are configured during the MoveIt! configuration process using the Setup Assistant tool.

The configuration file contains details about the kinematic solvers, joint limits, controllers, and so on that are also configured and saved during the configuration process.

Using the generated configuration package of the robot, we can work with motion planning in RViz without the presence of a real robot or simulation interface.

Let's start the configuration wizard, and we can see the step-by-step procedure to build the configuration...

Motion planning of a robot in RViz using the MoveIt! configuration package

MoveIt! provides an RViz plugin that allows developers to set the planning problem. From this plugin, the desired pose of the manipulator can be set, and a motion trajectory can be generated to test MoveIt! planning capabilities. To launch this plugin along with the robot model, we can directly use the MoveIt! launch files included in the MoveIt! configuration package. This package consists of configuration files and launch files to start motion planning in RViz. There is a demo launch file in the package to explore all the package's functionalities.

Here is the command to invoke the demo launch file:

roslaunch seven_dof_arm_config demo.launch  

If everything works fine, we will get the following screen of RViz being loaded with the MotionPlanning plugin provided by MoveIt!:

Figure 6.11 – MoveIt! RViz plugin

As you can see, from this plugin you can configure...

Understanding the ROS Navigation stack

The main aim of the ROS Navigation package is to move a robot from the start position to the goal position, without making any collision with the environment. The ROS Navigation package comes with an implementation of several navigation-related algorithms that can easily help implement autonomous navigation in mobile robots.

The user only needs to feed the goal position of the robot and the robot odometry data from sensors such as wheel encoders, Inertial Measurement Unit (IMU), and Global Positioning System (GPS), along with other sensor data streams, such as laser scanner data or 3D point cloud from sensors such as a Red-Green-Blue Depth (RGB-D) sensor. The output of the Navigation package will be the velocity commands that will drive the robot to the given goal position.

The Navigation stack contains the implementation of the standard algorithms, such as SLAM, A *(star), Dijkstra, amcl, and so on, that can directly be used in our...

Building a map using SLAM

Before to start configuring the Navigation stack, we need to install it. The ROS desktop full installation will not install the ROS Navigation stack. We must install the Navigation stack separately, using the following command:

sudo apt-get install ros-noetic-navigation  

After installing the Navigation package, let's start learning how to build a map of the robot environment. The robot we are using here is the differential wheeled robot that we discussed in the previous chapter. This robot satisfies all three requirements of the Navigation stack.

The ROS gmapping package is a wrapper of the open source implementation of SLAM, called OpenSLAM (https://openslam-org.github.io/gmapping.html). The package contains a node called slam_gmapping, which is the implementation of SLAM and helps to create a 2D occupancy grid map from the laser scan data and the mobile robot pose.

The basic hardware requirement for doing SLAM is a laser scanner...

Summary

This chapter offered a brief overview of MoveIt! and the Navigation stack of ROS and demonstrated its capabilities using Gazebo simulation of a robotic arm mobile base. The chapter started with a MoveIt! overview and discussed detailed concepts about MoveIt!. After discussing MoveIt!, we interfaced MoveIt! with Gazebo. After interfacing, we executed the trajectory from MoveIt! on Gazebo.

The next section was about the ROS Navigation stack. We discussed its concepts and workings as well. After discussing the concepts, we tried to interface our robot in Gazebo to the Navigation stack and build a map using SLAM. After this, we performed autonomous navigation using amcl and the static map.

In the next chapter, we will discuss pluginlib, nodelets, and controllers.

Here are few questions based on what we covered in this chapter.

Questions

  • What is the main purpose of MoveIt! packages?
  • What is the importance of the move_group node in MoveIt!?
  • What is the purpose of the move_base node in the Navigation stack?
  • What are the functions of the SLAM and amcl packages?
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering ROS for Robotics Programming, Third edition - Third Edition
Published in: Oct 2021Publisher: PacktISBN-13: 9781801071024
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

Authors (2)

author image
Lentin Joseph

Lentin Joseph is an author and robotics entrepreneur from India. He runs a robotics software company called Qbotics Labs in India. He has 7 years of experience in the robotics domain primarily in ROS, OpenCV, and PCL. He has authored four books in ROS, namely, Learning Robotics using Python, Mastering ROS for Robotics Programming, ROS Robotics Projects, and Robot Operating System for Absolute Beginners. He is currently pursuing his master's in Robotics from India and is also doing research at Robotics Institute, CMU, USA.
Read more about Lentin Joseph

author image
Jonathan Cacace

Jonathan Cacace was born in Naples, Italy, on December 13, 1987. He received his Master's degree in computer science, and a Ph.D. degree in Information and Automation Engineering, from the University of Naples Federico II. Currently, he is an Assistant Professor at the University of Naples Federico II. He is also a member of PRISMA Lab where he is involved in different research projects focused on industrial and service robotics in which he has developed several ROS-based applications integrating robot perception and control.
Read more about Jonathan Cacace