O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering ROS for Robotics Programming - Second Edition

Book Description

Discover best practices and troubleshooting solutions when working on ROS

About This Book

  • Develop complex robotic applications using ROS to interface robot manipulators and mobile robots
  • Gain insight into autonomous navigation in mobile robots and motion planning in robot manipulators
  • Discover best practices and troubleshooting solutions

Who This Book Is For

If you are a robotics enthusiast or researcher who want to learn more about building robot applications using ROS, this book is for you. In order to learn from this book, you should have a basic knowledge of ROS, GNU/Linux, and C++ programming concepts. The book is also excellent for programmers who want to explore the advanced features of ROS.

What You Will Learn

  • Create a robot model with a seven-DOF robotic arm and a differential wheeled mobile robot
  • Work with Gazebo and V-REP robotic simulator
  • Implement autonomous navigation in differential drive robots using SLAM and AMCL packages
  • Explore the ROS Pluginlib, ROS nodelets, and Gazebo plugins
  • Interface I/O boards such as Arduino, robot sensors, and high-end actuators
  • Simulate and motion plan an ABB and universal arm using ROS Industrial
  • Explore the latest version of the ROS framework
  • Work with the motion planning of a seven-DOF arm using MoveIt!

In Detail

In this day and age, robotics has been gaining a lot of traction in various industries where consistency and perfection matter. Automation is achieved via robotic applications and various platforms that support robotics. The Robot Operating System (ROS) is a modular software platform to develop generic robotic applications. This book focuses on the most stable release of ROS (Kinetic Kame), discusses advanced concepts, and effectively teaches you programming using ROS.

We begin with aninformative overview of the ROS framework, which will give you a clear idea of how ROS works. During the course of this book, you'll learn to build models of complex robots, and simulate and interface the robot using the ROS MoveIt! motion planning library and ROS navigation stacks. Learn to leverage several ROS packages to embrace your robot models.

After covering robot manipulation and navigation, you'll get to grips with the interfacing I/O boards, sensors, and actuators of ROS. Vision sensors are a key component of robots, and an entire chapter is dedicated to the vision sensor and image elaboration, its interface in ROS and programming. You'll also understand the hardware interface and simulation of complex robots to ROS and ROS Industrial.

At the end of this book, you'll discover the best practices to follow when programming using ROS.

Style and approach

This is a simplified guide to help you learn and master advanced topics in ROS using hands-on examples.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering ROS for Robotics Programming Second Edition
  3. www.PacktPub.com
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Introduction to ROS
    1. Why should we learn ROS?
    2. Why we prefer ROS for robots
    3. Why some do not prefer ROS for robots
    4. Understanding the ROS filesystem level
      1. ROS packages
      2. ROS metapackages
      3. ROS messages
      4. The ROS services
    5. Understanding the ROS computation graph level
      1. ROS nodes
      2. ROS messages
      3. ROS topics
      4. ROS services
      5. ROS bags
      6. The ROS Master
      7. Using the ROS parameter
    6. ROS community level
    7. What are the prerequisites for starting with ROS?
      1. Running the ROS Master and the ROS parameter server
        1. Checking the roscore command output
    8. Questions
    9. Summary
  7. Getting Started with ROS Programming
    1. Creating a ROS package
      1. Working with ROS topics
      2. Creating ROS nodes
      3. Building the nodes
    2. Adding custom msg and srv files
    3. Working with ROS services
      1. Working with ROS actionlib
        1. Creating the ROS action server
        2. Creating the ROS action client
      2. Building the ROS action server and client
    4. Creating launch files
    5. Applications of topics, services, and actionlib
    6. Maintaining the ROS package
    7. Releasing your ROS package
    8. Preparing the ROS package for the release
    9. Releasing our package
      1. Creating a Wiki page for your ROS package
    10. Questions
    11. Summary
  8. Working with 3D Robot Modeling in ROS
    1. ROS packages for robot modeling
    2. Understanding robot modeling using URDF
    3. Creating the ROS package for the robot description
    4. Creating our first URDF model
    5. Explaining the URDF file
    6. Visualizing the 3D robot model in RViz
      1. Interacting with pan-and-tilt joints
    7. Adding physical and collision properties to a URDF model
    8. Understanding robot modeling using xacro
      1. Using properties
      2. Using the math expression
      3. Using macros
    9. Converting xacro to URDF
    10. Creating the robot description for a seven DOF robot manipulator
      1. Arm specification
        1. Type of joints
    11. Explaining the xacro model of the seven DOF arm
      1. Using constants
      2. Using macros
      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
        1. Understanding joint state publisher
        2. Understanding robot state publisher
    12. Creating a robot model for the differential drive mobile robot
    13. Questions
    14. Summary
  9. Simulating Robots Using ROS and Gazebo
    1. Simulating the robotic arm using Gazebo and ROS
    2. 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
      3. Adding the gazebo_ros_control plugin
      4. Adding a 3D vision sensor to Gazebo
    3. Simulating the robotic arm with Xtion Pro
      1. Visualizing the 3D sensor data
    4. Moving 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 joint state controllers and joint position controllers to the arm
      5. Launching the ROS controllers with Gazebo
      6. Moving the robot joints
    5. 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 in the launch file
    6. Adding the ROS teleop node
    7. Questions
    8. Summary
  10. Simulating Robots Using ROS and V-REP
    1. Setting up V-REP with ROS
    2. Understanding the vrep_plugin
      1. Interacting with V-REP using ROS services
      2. Interacting with V-REP using ROS topics
    3. Simulating the robotic arm using V-REP and ROS
      1. Adding the ROS interface to V-REP joint controllers
    4. Simulating a differential wheeled robot in V-REP
      1. Adding a laser sensor to V-REP
      2. Adding a 3D vision sensor to V-REP
    5. Questions
    6. Summary
  11. Using the ROS MoveIt! and Navigation Stack
    1. Installing MoveIt!
      1. 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
    2. Generating MoveIt! configuration package using the Setup Assistant tool
      1. Step 1 – Launching the Setup Assistant tool
      2. Step 2 – Generating the 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
    3. Motion planning of robot in RViz using MoveIt! configuration package
      1. Using the RViz Motion Planning plugin
      2. Interfacing the MoveIt! configuration package to Gazebo
        1. Step 1 – Writing the controller configuration file for MoveIt!
        2. Step 2 – Creating the controller launch files
        3. Step 3 – Creating the controller configuration file for Gazebo
        4. Step 4 – Creating the launch file for Gazebo trajectory controllers
        5. Step 5 – Debugging the Gazebo- MoveIt! interface
    4. Understanding the ROS Navigation stack
      1. ROS Navigation hardware requirements
      2. Working with Navigation packages
        1. Understanding the move_base node
        2. Working of Navigation stack
        3. Localizing on the map
        4. Sending a goal and path planning
        5. Collision recovery behavior
        6. Sending the command velocity
    5. Installing the ROS 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. Questions
    8. Summary
  12. Working with pluginlib, Nodelets, and Gazebo Plugins
    1. Understanding pluginlib
      1. Creating plugins for the calculator application using pluginlib
        1. Working with the pluginlib_calculator package
          1. Step 1 - Creating the calculator_base header file
          2. Step 2 - Creating the calculator_plugins header file
          3. Step 3 - Exporting plugins using the calculator_plugins.cpp
          4. Step 4 - Implementing  the plugin loader using the calculator_loader.cpp
          5. Step 5 - Creating the plugin description file: calculator_plugins.xml
          6. Step 6 - Registering the plugin with the ROS package system
          7. Step 7 - Editing the CMakeLists.txt file
          8. Step 8 - Querying the list of plugins in a package
          9. Step 9 - Running the plugin loader
    2. Understanding ROS nodelets
      1. Creating a nodelet
        1. Step 1 - Creating a package for a nodelet
        2. Step 2 - Creating the hello_world.cpp nodelet
        3. Step 3 - Explanation of hello_world.cpp
        4. Step 4 - Creating the plugin description file
        5. Step 5 - Adding the export tag in package.xml
        6. Step 6 - Editing CMakeLists.txt
        7. Step 7 - Building and running nodelets
        8. Step 8 - Creating launch files for nodelets
    3. Understanding the Gazebo plugins
      1. Creating a basic world plugin
    4. Questions
    5. Summary
  13. Writing ROS Controllers and Visualization Plugins
    1. Understanding ros_control packages
      1. The controller_interface package
        1. Initializating the controller
        2. Starting the ROS controller
        3. Updating the ROS controller
        4. Stopping the controller
      2. The controller_manager
    2. 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 – Explaining 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
    3. Understanding the ROS visualization tool (RViz) and its plugins
      1. Displays panel
      2. RViz toolbar
      4. Time panel
      5. Dockable panels
    4. Writing an RViz plugin for teleoperation
      1. Methodology of building the RViz plugin
        1. Step 1 – Creating the RViz plugin package
        2. Step 2 – Creating the RViz plugin header file
        3. Step 3 – Creating the RViz plugin definition
        4. Step 4 – Creating the plugin description file
        5. Step 5 – Adding the export tags in package.xml
        6. Step 6 – Editing CMakeLists.txt
        7. Step 7 – Building and loading plugins
    5. Questions
    6. Summary
  14. Interfacing I/O Boards, Sensors, and Actuators to ROS
    1. Understanding the Arduino-ROS interface
    2. What is the Arduino-ROS interface?
      1. Understanding the rosserial package in ROS
        1. Installing rosserial packages on Ubuntu 16.04
      2. Understanding ROS node APIs in Arduino
      3. ROS - Arduino Publisher and Subscriber example
      4. Arduino-ROS, example - blink LED and push button
      5. Arduino-ROS, example - Accelerometer ADXL 335
      6. Arduino-ROS, example - ultrasonic distance sensor
        1. Equations to find distance using the ultrasonic range sensor
      7. Arduino-ROS example - Odometry Publisher
    3. Interfacing non-Arduino boards to ROS
      1. Setting ROS on Odroid-XU4 and Raspberry Pi 2
        1. How to install an OS image to Odroid-XU4 and Raspberry Pi 2
          1. Installation in Windows
          2. Installation in Linux
        2. Connecting to Odroid-XU4 and Raspberry Pi 2 from a PC
        3. Configuring an Ethernet hotspot for Odroid-XU4 and Raspberry Pi 2
          1. Installing Wiring Pi on Odroid-XU4
          2. Installing Wiring Pi on Raspberry Pi 2
      2. Blinking LED using ROS on Raspberry Pi 2
      3. Push button + blink LED using ROS on Raspberry Pi 2
      4. Running examples in Raspberry Pi 2
    4. Interfacing DYNAMIXEL actuators to ROS
    5. Questions
    6. Summary
  15. Programming Vision Sensors Using ROS, Open CV, and PCL
    1. Understanding ROS – OpenCV interfacing packages
    2. Understanding ROS - PCL interfacing packages
      1. Installing ROS perception
    3. Interfacing USB webcams in ROS
    4. Working with ROS camera calibration
      1. Converting images between ROS and OpenCV using cv_bridge
      2. Image processing using ROS and OpenCV
        1. Step 1 – Creating a ROS package for the experiment
        2. Step 2 – Creating source files
        3. Step 3 – Explanation of the code
          1. Publishing and subscribing images using image_transport
          2. Converting OpenCV to ROS images using cv_bridge
          3. Finding edges on the image
          4. Visualizing raw and edge-detected-images
        4. Step 4 – Editing the CMakeLists.txt file
        5. Step 5 – Building and running an example
    5. Interfacing Kinect and Asus Xtion Pro in ROS
    6. Interfacing Intel Real Sense camera with ROS
      1. Working with a point cloud to a laser scan package
    7. Interfacing Hokuyo Laser in ROS
    8. Working with point cloud data
      1. How to publish a point cloud
      2. How to subscribe and process the point cloud
      3. Writing data to a Point Cloud Data (PCD) file
      4. Reading and publishing a point cloud from a PCD file
    9. Working with AR Marker detection for object pose estimation
      1. Using AprilTag with ROS
    10. Questions
    11. Summary
  16. Building and Interfacing Differential Drive Mobile Robot Hardware in ROS
    1. Introducing to Chefbot – a DIY mobile robot and its hardware configuration
      1. Flashing Chefbot firmware using Energia IDE
        1. Serial data sending protocol from LaunchPad to PC
        2. Serial data sending protocol from PC to Launchpad
      2. Discussing Chefbot interface packages on ROS
      3. Computing odometry from encoder ticks
      4. Computing motor velocities from ROS twist message
        1. Running the robot standalone launch file using C++ nodes
      5. Configuring the Navigation stack for Chefbot
      6. Configuring the gmapping node
      7. Configuring the Navigation stack packages
        1. Common configuration local_costmap and global_costmap
        2. Configuring global costmap parameters
        3. Configuring local costmap parameters
        4. Configuring base local planner parameters
        5. Configuring DWA local planner parameters
        6. Configuring move_base node parameters
      8. Understanding AMCL
      9. Understanding RViz for working with the Navigation stack
        1. 2D Pose Estimate button
        2. Visualizing the particle cloud
        3. The 2D Nav Goal button
        4. Displaying the static map
        5. Displaying the robot footprint
        6. Displaying the global and local cost map
        7. Displaying the global plan, the local plan, and the planner plan
        8. The current goal
      10. Obstacle avoidance using the Navigation stack
      11. Working with Chefbot simulation
        1. Building a room in Gazebo
        2. Adding model files to the Gazebo model folder
      12. Sending a goal to the Navigation stack from a ROS node
    2. Questions
    3. Summary
  17. Exploring the Advanced Capabilities of ROS-MoveIt!
    1. 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
    2. Collision checking with a robot arm using MoveIt!
      1. Adding a collision object to MoveIt!
      2. Removing a collision object from the planning scene
      3. Attaching a collision object to a robot link
      4. Checking self-collisions using MoveIt! APIs
    3. Working with perception using MoveIt! and Gazebo
      1. Manipulating objects with MoveIt!
    4. Working with a robot pick-and-place task using MoveIt!
      1. Calculating grasp poses with GPD
      2. Pick and place action in Gazebo and real robot
    5. Understanding DYNAMIXEL ROS Servo controllers for robot hardware interfacing
      1. The DYNAMIXEL servos
      2. DYNAMIXEL-ROS interface
    6. Interfacing 7 DOF DYNAMIXEL-based robotic arm to ROS MoveIt!
      1. Creating a controller package for a COOL arm robot
      2. MoveIt! configuration of the COOL Arm
    7. Questions
    8. Summary
  18. Using ROS in MATLAB and Simulink
    1. Getting started with MATLAB and MATLAB-ROS
      1. Getting started with the Robotic System Toolbox and ROS-MATLAB interface
      2. Starting with ROS topics and MATLAB callback functions
      3. Implementing an obstacle avoidance system for a Turtlebot robot
    2. Getting started with ROS and Simulink
      1. Creating a wave signal integrator in Simulink
      2. Working with ROS messages in Simulink
      3. Publishing a ROS message in Simulink
      4. Subscribing to a ROS topic in Simulink
    3. Developing a simple control system in Simulink
      1. Configuring the Simulink model
    4. Questions
    5. Summary
  19. ROS for Industrial Robots
    1. Understanding ROS-Industrial packages
      1. Goals of ROS-Industrial
      2. ROS-Industrial – a brief history
      3. Benefits of ROS-Industrial
    2. Installing ROS-Industrial packages
    3. Block diagram of ROS-Industrial packages
    4. Creating a URDF for an industrial robot
    5. Creating the MoveIt! configuration for an industrial robot
      1. Updating the MoveIt! configuration files
      2. Testing the MoveIt! configuration
    6. Installing ROS-Industrial packages of  Universal robotic arms
      1. Installing the ROS interface of Universal Robots
    7. Understanding the Moveit! configuration of a Universal Robot arm
    8. Getting started with real Universal Robots hardware and ROS-I
    9. Working with MoveIt! configuration of ABB robots
    10. Understanding the ROS-Industrial robot support packages
      1. Visualizing the ABB robot model in RViz
    11. ROS-Industrial robot client package
      1. Designing industrial robot client nodes
    12. ROS-Industrial robot driver package
    13. Understanding the MoveIt! IKFast plugin
    14. Creating the MoveIt! IKFast plugin for the ABB IRB 6640 robot
      1. Prerequisites for developing the MoveIt! IKFast plugin
      2. OpenRave and IK Fast modules
        1. MoveIt! IKFast
        2. Installing the MoveIt! IKFast package
        3. Installing OpenRave on Ubuntu 16.04
    15. Creating the COLLADA file of a robot to work with OpenRave
    16. Generating the IKFast CPP file for the IRB 6640 robot
      1. Creating the MoveIt! IKFast plugin
    17. Questions
    18. Summary
  20. Troubleshooting and Best Practices in ROS
    1. Setting up RoboWare Studio in Ubuntu
      1. Installing/uninstalling RoboWare Studio
      2. Getting started with RoboWare Studio
      3. Create ROS packages in RoboWare Studio
      4. Building ROS workspace in RoboWare Studio
      5. Executing ROS nodes in RoboWare Studio
      6. Starting ROS tools from the RoboWare interface
      7. Handling active ROS topics, nodes, and services
      8. Creating ROS nodes and classes with RoboWare tools
      9. ROS package manager in RoboWare Studio
    2. Best practices in ROS
      1. ROS C++ coding style guide
        1. Standard naming conventions used in ROS
        2. Code license agreement
        3. ROS code formatting
        4. Console output
    3. Best practices in the ROS package
    4. Important troubleshooting tips in ROS
      1. Using roswtf
    5. Questions
    6. Summary
  21. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think