Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering ROS for Robotics Programming
Mastering ROS for Robotics Programming

Mastering ROS for Robotics Programming: Design, build, and simulate complex robots using the Robot Operating System , Second Edition

eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Mastering ROS for Robotics Programming

Getting Started with ROS Programming

After discussing the basics of the ROS Master, the parameter server, and roscore , we can now start to create and build a ROS package. In this chapter, we will create different ROS nodes implementing the ROS communication system. Working with ROS packages, we will also refresh the concepts of ROS nodes, topics, messages, services, and actionlib.

We will cover the following list of topics:

  • Creating, compiling and running ROS packages.
  • Working with standard and custom ROS messages.
  • Working with ROS services and actionlib.
  • Maintaining and releasing your ROS packages.
  • Creating a wiki page for ROS packages.

Creating a ROS package

The ROS packages are the basic unit of the ROS system. We can create a ROS package, build it, and release it to the public. The current distribution of ROS we are using is kinetic. We are using the catkin build system to build ROS packages. A build system is responsible for generating 'targets' (executable/libraries) from a raw source code that can be used by an end user. In older distributions, such as Electric and Fuerte, rosbuild was the build system. Because of the various flaws of rosbuild, catkin came into existence, which is basically based on Cross Platform Make (CMake). This has a lot of advantages, such as porting the package into another operating system, such as Windows. If an OS supports CMake and Python, catkin -based packages can be easily ported into it.

The first requirement work with ROS packages is to create a...

Adding custom msg and srv files

In this section, we will look at how to create custom messages and services definitions in the current package. The message definitions are stored in a .msg file and the service definitions are stored in a .srv file. These definitions inform ROS about the type of data and name of data to be transmitted from a ROS node. When a custom message is added, ROS will convert the definitions into equivalent C++ codes, which we can include in our nodes.

We can start with message definitions. Message definitions have to be written in the .msg file and have to be kept in the msg folder, which is inside the package. We are going to create a message file called demo_msg.msg with the following definition:

string greeting 
int32 number 

Until now, we have worked only with standard message definitions. Now, we have created our own definitions and can see how to...

Working with ROS services

In this section, we are going to create ROS nodes, which can use the services definition that we defined already. The service nodes we are going to create can send a string message as a request to the server and the server node will send another message as a response.

Navigate to mastering_ros_demo_pkg/src, and find nodes with the names demo_service_server.cpp and demo_service_client.cpp.

The demo_service_server.cpp is the server, and its definition is as follows:

#include "ros/ros.h" 
#include "mastering_ros_demo_pkg/demo_srv.h" 
#include <iostream> 
#include <sstream> 
using namespace std; 
 
bool demo_service_callback(mastering_ros_demo_pkg::demo_srv::Request &req, 
     mastering_ros_demo_pkg::demo_srv::Response &res) { 
 std::stringstream ss; 
 ss << "Received Here"; 
 res.out = ss.str(); 
...

Creating launch files

The launch files in ROS are a very useful feature for launching more than one node. In the preceding examples, we have seen a maximum of two ROS nodes, but imagine a scenario in which we have to launch 10 or 20 nodes for a robot. It will be difficult if we run each node in a terminal one by one. Instead, we can write all nodes inside an XML-based file called launch files and, using a command called roslaunch, we can parse this file and launch the nodes.

The roslaunch command will automatically start the ROS Master and the parameter server. So, in essence, there is no need to start the roscore command and individual node; if we launch the file, all operations will be done in a single command.

Let's start creating launch files. Switch to the package folder and create a new launch file called demo_topic.launch to launch two ROS nodes that are publishing...

Applications of topics, services, and actionlib

Topics, services, and actionlib are used in different scenarios. We know topics are a unidirectional communication method, services are a bidirectional request/reply kind of communication, and actionlib is a modified form of ROS services in which we can cancel the executing process running on the server whenever required.

Here are some of the areas where we use these methods:

  • Topics: Streaming continuous data flow, such as sensor data. For example, stream joypad data to teleoperate a robot, publish robot odometry, publish video stream from a camera.
  • Services: Executing procedures that terminate quickly. For example, save calibration parameter of sensors, save a map generated by the robot during its navigation, or load a parameter file.
  • Actionlib: Execute long and complex actions managing their feedback. For example, navigate towards...

Maintaining the ROS package

Most ROS packages are maintained using a Version Control System (VCS) such as Git, Subversion (svn), Mercurial (hg), and so on. A collection of packages that share a common VCS can be called a repository. The package in the repository can be released using a catkin release automation tool called bloom. Most ROS packages are released as open source with the BSD license. There are active developers around the globe who are contributing to the ROS platform. Maintaining packages is important for all software, especially open source applications. Open source software is maintained and supported by a community of developers. Creating a version control system for our package is essential if we want to maintain and accept a contribution from other developers.
The preceding package is already updated in GitHub, and you can view the source code of the project...

Releasing your ROS package

After creating a ROS package in GitHub, we can officially release our package. ROS provides detailed steps to release the ROS package using a tool called bloom (http://ros-infrastructure.github.io/bloom/). Bloom is a release automation tool, designed to make platform-specific releases from the source projects. Bloom is designed to work best with the catkin project.

The prerequisites for releasing the package are as follows:

  • Install the Bloom tool
  • Create a Git repository for the current package
  • Create an empty Git repository for the release

The following command will install bloom in Ubuntu:

$ sudo apt-get install python-bloom  

Create a Git repository for the current package. The repository that has the package is called the upstream repository. Here, we already created a repository at https://github.com/jocacace/mastering_ros_demo_pkg.

Create an empty...

Creating a ROS package


The ROS packages are the basic unit of the ROS system. We can create a ROS package, build it, and release it to the public. The current distribution of ROS we are using is kinetic. We are using the catkin build system to build ROS packages. A build system is responsible for generating 'targets' (executable/libraries) from a raw source code that can be used by an end user. In older distributions, such as Electric and Fuerte, rosbuild was the build system. Because of the various flaws of rosbuild, catkin came into existence, which is basically based on Cross Platform Make (CMake). This has a lot of advantages, such as porting the package into another operating system, such as Windows. If an OS supports CMake and Python, catkin -based packages can be easily ported into it.

The first requirement work with ROS packages is to create a ROS catkin workspace. After installed ROS, we can create and build a catkin_workspace called catkin_ws:

$ mkdir -p ~/catkin_ws/src

To compile...

Adding custom msg and srv files


In this section, we will look at how to create custom messages and services definitions in the current package. The message definitions are stored in a .msg file and the service definitions are stored in a .srv file. These definitions inform ROS about the type of data and name of data to be transmitted from a ROS node. When a custom message is added, ROS will convert the definitions into equivalent C++ codes, which we can include in our nodes.

We can start with message definitions. Message definitions have to be written in the .msg file and have to be kept in the msg folder, which is inside the package. We are going to create a message file called demo_msg.msg with the following definition:

string greeting 
int32 number 

Until now, we have worked only with standard message definitions. Now, we have created our own definitions and can see how to use them in our code.

The first step is to edit the package.xml file of the current package and uncomment the lines ...

Working with ROS services


In this section, we are going to create ROS nodes, which can use the services definition that we defined already. The service nodes we are going to create can send a string message as a request to the server and the server node will send another message as a response.

Navigate to mastering_ros_demo_pkg/src, and find nodes with the names demo_service_server.cpp and demo_service_client.cpp.

The demo_service_server.cpp is the server, and its definition is as follows:

#include "ros/ros.h" 
#include "mastering_ros_demo_pkg/demo_srv.h" 
#include <iostream> 
#include <sstream> 
using namespace std; 
 
bool demo_service_callback(mastering_ros_demo_pkg::demo_srv::Request &req, 
     mastering_ros_demo_pkg::demo_srv::Response &res) { 
 std::stringstream ss; 
 ss << "Received Here"; 
 res.out = ss.str(); 
 ROS_INFO("From Client [%s], Server says [%s]",req.in.c_str(),res.out.c_str()); 
 return true; 
} 
 
int main(int argc, char **argv) 
{ 
 ros::init...

Creating launch files


The launch files in ROS are a very useful feature for launching more than one node. In the preceding examples, we have seen a maximum of two ROS nodes, but imagine a scenario in which we have to launch 10 or 20 nodes for a robot. It will be difficult if we run each node in a terminal one by one. Instead, we can write all nodes inside an XML-based file called launch files and, using a command called roslaunch, we can parse this file and launch the nodes.

The roslaunch command will automatically start the ROS Master and the parameter server. So, in essence, there is no need to start the roscore command and individual node; if we launch the file, all operations will be done in a single command.

Let's start creating launch files. Switch to the package folder and create a new launch file called demo_topic.launch to launch two ROS nodes that are publishing and subscribing an integer value. We keep the launch files in a launch folder, which is inside the package:

$ roscd mastering_ros_demo_pkg...
Left arrow icon Right arrow icon

Key benefits

  • • 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

Description

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.

Who is this book 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!

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 26, 2018
Length: 580 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788474528
Category :
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Feb 26, 2018
Length: 580 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788474528
Category :
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 158.97
ROS Robotics By Example, Second Edition
€41.99
Mastering ROS for Robotics Programming
€41.99
ROS Programming: Building Powerful Robots
€74.99
Total 158.97 Stars icon

Table of Contents

16 Chapters
Introduction to ROS Chevron down icon Chevron up icon
Getting Started with ROS Programming Chevron down icon Chevron up icon
Working with 3D Robot Modeling in ROS Chevron down icon Chevron up icon
Simulating Robots Using ROS and Gazebo Chevron down icon Chevron up icon
Simulating Robots Using ROS and V-REP Chevron down icon Chevron up icon
Using the ROS MoveIt! and Navigation Stack Chevron down icon Chevron up icon
Working with pluginlib, Nodelets, and Gazebo Plugins Chevron down icon Chevron up icon
Writing ROS Controllers and Visualization Plugins Chevron down icon Chevron up icon
Interfacing I/O Boards, Sensors, and Actuators to ROS Chevron down icon Chevron up icon
Programming Vision Sensors Using ROS, Open CV, and PCL Chevron down icon Chevron up icon
Building and Interfacing Differential Drive Mobile Robot Hardware in ROS Chevron down icon Chevron up icon
Exploring the Advanced Capabilities of ROS-MoveIt! Chevron down icon Chevron up icon
Using ROS in MATLAB and Simulink Chevron down icon Chevron up icon
ROS for Industrial Robots Chevron down icon Chevron up icon
Troubleshooting and Best Practices in ROS Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(2 Ratings)
5 star 50%
4 star 0%
3 star 0%
2 star 0%
1 star 50%
Neil John Sep 18, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is an updated version of Mastering ROS book, and this helped me to finish a project. Learning from ROS wiki is time consuming that's why I have looked for books. This was a perfect suit for my project.
Amazon Verified review Amazon
Developer Feb 19, 2019
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
I’m hoping this gets better, chapter 1 is deep dive into configuration files and pseudo-bash commands with little focus on the big picture. There is no glue holding this together, and skimming through the upcoming chapters it doesn’t appear to get better. It just feels very clunky, as if each section were written by different people and tossed together in no particular order, lacking any meaningful examples, etc.I’ll update this review if necessary, but as of now, I would not recommend this to anyone.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.