Mastering ROS for Robotics Programming - Third Edition

Book description

Design, build, and simulate complex robots using the Robot Operating System

Key Features

  • Become proficient in ROS programming using C++ with this comprehensive guide
  • Build complex robot applications using the ROS Noetic Ninjemys release to interface robot manipulators with mobile robots
  • Learn to interact with aerial robots using ROS

Book Description

The Robot Operating System (ROS) is a software framework used for programming complex robots. ROS enables you to develop software for building complex robots without writing code from scratch, saving valuable development time. Mastering ROS for Robotics Programming provides complete coverage of the advanced concepts using easy-to-understand, practical examples and step-by-step explanations of essential concepts that you can apply to your ROS robotics projects.

The book begins by helping you get to grips with the basic concepts necessary for programming robots with ROS. You'll then discover how to develop a robot simulation, as well as an actual robot, and understand how to apply high-level capabilities such as navigation and manipulation from scratch. As you advance, you'll learn how to create ROS controllers and plugins and explore ROS's industrial applications and how it interacts with aerial robots. Finally, you'll discover best practices and methods for working with ROS efficiently.

By the end of this ROS book, you'll have learned how to create various applications in ROS and build your first ROS robot.

What you will learn

  • Create a robot model with a 7-DOF robotic arm and a differential wheeled mobile robot
  • Work with Gazebo, CoppeliaSim, and Webots robotic simulators
  • Implement autonomous navigation in differential drive robots using SLAM and AMCL packages
  • Interact with and simulate aerial robots using ROS
  • Explore ROS pluginlib, ROS nodelets, and Gazebo plugins
  • Interface I/O boards such as Arduino, robot sensors, and high-end actuators
  • Simulate and perform motion planning for an ABB robot and a universal arm using ROS-Industrial
  • Work with the motion planning features of a 7-DOF arm using MoveIt

Who this book is for

If you are a robotics graduate, robotics researcher, or robotics software professional looking to work with ROS, this book is for you. Programmers who want to explore the advanced features of ROS will also find this book useful. Basic knowledge of ROS, GNU/Linux, and C++ programming concepts is necessary to get started with this book.

Table of contents

  1. Mastering ROS for Robotics Programming Third Edition
  2. Contributors
  3. About the authors
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Code in Action
    6. Download the color images
    7. Conventions used
    8. Get in touch
    9. Share Your Thoughts
  6. Section 1 – ROS Programming Essentials
  7. Chapter 1: Introduction to ROS
    1. Technical requirements
    2. Why should we use ROS?
    3. Understanding the ROS filesystem level
      1. ROS packages
      2. ROS metapackages
      3. ROS messages
      4. The ROS services
    4. Understanding the ROS computation graph level
      1. ROS nodes
      2. ROS messages
      3. ROS topics
      4. ROS services
      5. ROS bagfiles
      6. The ROS master
      7. Using the ROS parameter
    5. ROS community level
    6. Prerequisites for starting with ROS
      1. ROS distributions
      2. Running the ROS master and the ROS parameter server
    7. Summary
    8. Questions
  8. Chapter 2: Getting Started with ROS Programming
    1. Technical requirements
    2. Creating a ROS package
      1. Working with ROS topics
      2. Creating ROS nodes
      3. Building the nodes
    3. Adding custom .msg and .srv files
    4. Working with ROS services
      1. Working with ROS actionlib
      2. Building the ROS action server and client
    5. Creating launch files
    6. Applications of topics, services, and actionlib
    7. Summary
    8. Questions
  9. Section 2 – ROS Robot Simulation
  10. Chapter 3: Working with ROS for 3D Modeling
    1. Technical requirements
    2. ROS packages for robot modeling
    3. Understanding robot modeling using URDF
    4. Creating the ROS package for the robot description
    5. Creating our first URDF model
    6. Explaining the URDF file
    7. Visualizing the 3D robot model in RViz
      1. Interacting with pan-and-tilt joints
    8. Adding physical and collision properties to a URDF model
    9. Understanding robot modeling using xacro
      1. Using properties
      2. Using the math expression
    10. Converting xacro to URDF
    11. Creating the robot description for a seven-DOF robot manipulator
      1. Arm specification
    12. Explaining the xacro model of the seven-DOF arm
      1. Using constants
      2. Using macro
      3. Including other xacro files
      4. Using meshes in the link
      5. Working with the robot gripper
      6. Viewing the seven-DOF arm in RViz
    13. Creating a robot model for the differential drive mobile robot
    14. Summary
    15. Questions
  11. Chapter 4: Simulating Robots Using ROS and Gazebo
    1. Technical requirements
    2. Simulating the robotic arm using Gazebo and ROS
    3. Creating the robotic arm simulation model for Gazebo
      1. Adding colors and textures to the Gazebo robot model
      2. Adding transmission tags to actuate the model
    4. Adding the gazebo_ros_control plugin
      1. Adding a 3D vision sensor to Gazebo
    5. Simulating the robotic arm with Xtion Pro
      1. Visualizing the 3D sensor data
    6. Moving the robot joints using ROS controllers in Gazebo
      1. Understanding the ros_control packages
      2. Different types of ROS controllers and hardware interfaces
      3. How the ROS controller interacts with Gazebo
      4. Interfacing the joint state controllers and joint position controllers with the arm
      5. Launching the ROS controllers with Gazebo
      6. Moving the robot joints
    7. Simulating a differential wheeled robot in Gazebo
      1. Adding the laser scanner to Gazebo
      2. Moving the mobile robot in Gazebo
      3. Adding joint state publishers to the launch file
    8. Adding the ROS teleop node
    9. Questions
    10. Summary
  12. Chapter 5: Simulating Robots Using ROS, CoppeliaSim, and Webots
    1. Technical requirements
    2. Setting up CoppeliaSim with ROS
      1. Understanding the RosInterface plugin
      2. Working with ROS messages
    3. Simulating a robotic arm using CoppeliaSim and ROS
      1. Adding the ROS interface to CoppeliaSim joint controllers
    4. Setting up Webots with ROS
      1. Introduction to the Webots simulator
      2. Simulating a mobile robot with Webots
    5. Writing your first controller
      1. Simulating the robotic arm using Webots and ROS
    6. Writing a teleop node using webots_ros
      1. Starting Webots with a launch file
    7. Summary
    8. Questions
  13. Chapter 6: Using the ROS MoveIt! and Navigation Stack
    1. Technical requirements
    2. The MoveIt! architecture
      1. The move_group node
      2. Motion planning using MoveIt!
      3. Motion-planning request adapters
      4. MoveIt! planning scene
      5. MoveIt! kinematics handling
      6. MoveIt! collision checking
    3. Generating a MoveIt! configuration package using the Setup Assistant tool
      1. Step 1 – Launching the Setup Assistant tool
      2. Step 2 – Generating a self-collision matrix
      3. Step 3 – Adding virtual joints
      4. Step 4 – Adding planning groups
      5. Step 5 – Adding the robot poses
      6. Step 6 – Setting up the robot end effector
      7. Step 7 – Adding passive joints
      8. Step 8 – Author information
      9. Step 9 – Generating configuration files
    4. Motion planning of a robot in RViz using the MoveIt! configuration package
      1. Using the RViz MotionPlanning plugin
      2. Interfacing the MoveIt! configuration package to Gazebo
    5. Understanding the ROS Navigation stack
      1. ROS Navigation hardware requirements
      2. Working with Navigation packages
      3. Workings of the Navigation stack
    6. Building a map using SLAM
      1. Creating a launch file for gmapping
      2. Running SLAM on the differential drive robot
      3. Implementing autonomous navigation using amcl and a static map
      4. Creating an amcl launch file
    7. Summary
    8. Questions
  14. Chapter 7: Exploring the Advanced Capabilities of ROS MoveIt!
    1. Technical requirements
    2. Motion planning using the move_group C++ interface
      1. Motion planning a random path using MoveIt! C++ APIs
      2. Motion planning a custom path using MoveIt! C++ APIs
      3. Collision checking with a robot arm using MoveIt!
    3. Working with perception using MoveIt! and Gazebo
    4. Performing object manipulation with MoveIt!
      1. Working with a robot pick-and-place task using MoveIt!
      2. Pick-and-place actions in Gazebo and real robots
    5. Understanding DYNAMIXEL ROS servo controllers for robot hardware interfacing
      1. DYNAMIXEL servos
      2. DYNAMIXEL-ROS interface
    6. Interfacing a 7-DOF DYNAMIXEL-based robotic arm with ROS MoveIt!
      1. Creating a controller package for a COOL arm robot
      2. MoveIt! configuration of the COOL arm
    7. Summary
    8. Questions
  15. Chapter 8: ROS for Aerial Robots
    1. Technical requirements
    2. Using aerial robots
      1. UAV hardware
      2. Pixhawk autopilot
    3. Using the PX4 flight control stack
      1. PX4 firmware architecture
      2. PX4 SITL
    4. PC/autopilot communication
      1. The mavros ROS package
    5. Writing a ROS-PX4 application
      1. Writing a trajectory streamer
      2. External pose estimation for PX4
    6. Using the RotorS simulation framework
      1. Installing RotorS
      2. RotorS packages
      3. Creating a new UAV model
      4. Interacting with RotorS motor models
    7. Summary
    8. Questions
  16. Section 3 – ROS Robot Hardware Prototyping
  17. Chapter 9: Interfacing I/O Board Sensors and Actuators to ROS
    1. Technical requirements:
    2. Understanding the Arduino-ROS interface
    3. What is the Arduino-ROS interface?
      1. Understanding the rosserial package in ROS
      2. Understanding ROS node APIs in Arduino
      3. ROS-Arduino Publisher and Subscriber example
      4. Arduino-ROS example – blinking an LED with a push button
      5. Arduino-ROS example – Accelerometer ADXL 335
      6. Arduino-ROS example – ultrasonic distance sensor
      7. Arduino-ROS example – odometry data publisher
    4. Interfacing non-Arduino boards to ROS
      1. Setting up the Odroid-C4, Raspberry Pi 4, and Jetson Nano for installing ROS
      2. Blinking the LED using ROS on the Raspberry Pi 4
      3. A push button and a blinking LED using ROS on the Raspberry Pi 2
      4. Running examples on the Raspberry Pi 4
    5. Interfacing DYNAMIXEL actuators to ROS
    6. Summary
    7. Questions
  18. Chapter 10: Programming Vision Sensors Using ROS, OpenCV, and PCL
    1. Technical requirements
    2. Understanding ROS – OpenCV interfacing packages
    3. Understanding ROS – PCL interfacing packages
      1. Installing ROS perception
    4. Interfacing USB webcams in ROS
    5. Working with ROS camera calibration
      1. Converting images between ROS and OpenCV using cv_bridge
    6. Interfacing Kinect and Asus Xtion Pro with ROS
    7. Interfacing the Intel RealSense camera with ROS
      1. Converting point cloud to a laser scan
    8. Interfacing Hokuyo lasers with ROS
      1. Interfacing RPLIDAR and YDLIDAR with ROS
    9. Working with point cloud data
      1. How to publish a point cloud
      2. How to subscribe and process a point cloud
      3. Reading and publishing a point cloud from a PCD file
    10. Summary
    11. Questions
  19. Chapter 11: Building and Interfacing Differential Drive Mobile Robot Hardware in ROS
    1. Technical requirements
      1. Software requirements
      2. Network setup
      3. Hardware requirements
    2. Introduction to the Remo robot – a DIY autonomous mobile robot
      1. Remo hardware components
      2. Software requirements for the ROS Navigation Stack
    3. Developing a low-level controller and a high-level ROS Control hardware interface for a differential drive robot
      1. Implementing the low-level base controller for Remo
      2. ROS Control high-level hardware interface for a differential drive robot
      3. Overview of ROS nodes and topics for the Remo robot
    4. Configuring and working with the Navigation Stack
      1. Configuring the gmapping node and creating a map
      2. Working with the gmapping node
      3. Configuring the move_base node
      4. Configuring the AMCL node
      5. AMCL planning
      6. Working with Remo robot in simulation
    5. Summary
    6. Questions
  20. Section 4 – Advanced ROS Programming
  21. Chapter 12: Working with pluginlib, nodelets, and Gazebo Plugins
    1. Technical requirements
    2. Understanding pluginlib
      1. Implementing a calculator plugin using pluginlib
    3. Understanding ROS nodelets
      1. Implementing a sample nodelet
    4. Understanding and creating a Gazebo plugin
      1. Creating a basic world plugin
    5. Summary
    6. Questions
  22. Chapter 13: Writing ROS Controllers and Visualization Plugins
    1. Technical requirements
    2. Understanding ros_control packages
      1. The controller_interface package
    3. Writing a basic joint controller in ROS
      1. Step 1 – creating the controller package
      2. Step 2 – creating the controller header file
      3. Step 3 – creating the controller source file
      4. Step 4 – detailed explanation of the controller source file
      5. Step 5 – creating the plugin description file
      6. Step 6 – updating package.xml
      7. Step 7 – updating CMakeLists.txt
      8. Step 8 – building the controller
      9. Step 9 – writing the controller configuration file
      10. Step 10 – writing the launch file for the controller
      11. Step 11 – running the controller along with the seven-DOF arm in Gazebo
    4. Understanding the RViz tool and its plugins
      1. The Displays panel
      2. The RViz toolbar
      3. The Views panel
      4. The Time panel
      5. Dockable panels
    5. Writing an RViz plugin for teleoperation
      1. The methodology of building a RViz plugin
    6. Summary
    7. Questions
  23. Chapter 14: Using ROS in MATLAB and Simulink
    1. Technical requirements
    2. Getting started with MATLAB
    3. Getting started with ROS Toolbox and MATLAB
      1. Starting with ROS topics and MATLAB callback functions
    4. Developing a robotic application using MATLAB and Gazebo
    5. Getting started with ROS and Simulink
      1. Creating a wave signal integrator in Simulink
      2. Publishing a ROS message in Simulink
      3. Subscribing to a ROS topic in Simulink
    6. Developing a simple control system in Simulink
      1. Configuring the Simulink model
    7. Summary
    8. Questions
  24. Chapter 15: ROS for Industrial Robots
    1. Technical requirements
    2. Understanding ROS-Industrial packages
    3. Goals of ROS-Industrial
    4. ROS-Industrial – a brief history
    5. Installing ROS-Industrial packages
      1. Block diagram of ROS-Industrial packages
    6. Creating a URDF for an industrial robot
    7. Creating the MoveIt configuration for an industrial robot
    8. Updating the MoveIt configuration files
    9. Installing ROS-Industrial packages for Universal Robots arms
    10. Installing the ROS interface for Universal Robots
    11. Understanding the MoveIt configuration of a Universal Robots arm
    12. Getting started with real Universal Robots hardware and ROS-I
    13. Working with MoveIt configuration for ABB robots
    14. Understanding the ROS-Industrial robot support packages
    15. The ROS-Industrial robot client package
    16. Designing industrial robot client nodes
    17. The ROS-Industrial robot driver package
    18. Understanding the MoveIt IKFast plugin
    19. Creating the MoveIt IKFast plugin for the ABB IRB 6640 robot
      1. Prerequisites for developing the MoveIt IKFast plugin
    20. The OpenRave and IKFast modules
      1. MoveIt IKFast
      2. Installing the MoveIt IKFast package
      3. Installing OpenRave on Ubuntu 20.04
    21. Creating the COLLADA file of a robot to work with OpenRave
    22. Generating the IKFast CPP file for the IRB 6640 robot
    23. Creating the MoveIt IKFast plugin
    24. Summary
    25. Questions
  25. Chapter 16: Troubleshooting and Best Practices in ROS
    1. Setting up Visual Studio Code with ROS
      1. Installing/uninstalling Visual Studio Code
      2. Getting started with Visual Studio Code
      3. Installing new Visual Studio Code extensions
      4. Getting started with the Visual Studio Code ROS extension
      5. Inspecting and building the ROS workspace
      6. Managing ROS packages using Visual Studio Code
      7. Visualizing the preview of a URDF file
    2. Best practices in ROS
      1. ROS C++ coding style guide
    3. Best coding practices for the ROS package
    4. Important troubleshooting tips in ROS
      1. Using roswtf
    5. Summary
    6. Questions
    7. Why subscribe?
  26. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Mastering ROS for Robotics Programming - Third Edition
  • Author(s): Lentin Joseph, Jonathan Cacace
  • Release date: October 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781801071024