Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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

Arrow left icon
Profile Icon Lentin Joseph
Arrow right icon
Can$12.99 Can$61.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (10 Ratings)
eBook Dec 2015 480 pages 1st Edition
eBook
Can$12.99 Can$61.99
Paperback
Can$77.99
Subscription
Free Trial
Arrow left icon
Profile Icon Lentin Joseph
Arrow right icon
Can$12.99 Can$61.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (10 Ratings)
eBook Dec 2015 480 pages 1st Edition
eBook
Can$12.99 Can$61.99
Paperback
Can$77.99
Subscription
Free Trial
eBook
Can$12.99 Can$61.99
Paperback
Can$77.99
Subscription
Free Trial

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

Chapter 2. Working with 3D Robot Modeling in ROS

The first phase of robot manufacturing is its design and modeling. We can design and model the robot using CAD tools such as AutoCAD, Solid Works, Blender, and so on. One of the main purposes of modeling robot is simulation.

The robotic simulation tool can check the critical flaws in the robot design and can confirm the working of the robot before it goes to the manufacturing phase.

The virtual robot model must have all the characteristics of real hardware, the shape of robot may or may not look like the actual robot but it must be an abstract, which has all the physical characteristics of the actual robot.

In this chapter, we are going to discuss the designing of two robots. One is a seven DOF ( Degrees of Freedom) manipulator and the other is a differential drive robot. In the upcoming chapters, we can see its simulation and how to build the real hardware and finally, it's interfacing to ROS.

If we are planning to create the...

ROS packages for robot modeling

ROS provides some good packages that can be used to build 3D robot models. In this section, we will discuss some of the important ROS packages that are commonly used to build robot models:

  • robot_model: ROS has a meta package called robot_model, which contains important packages that help build the 3D robot models. We can see all the important packages inside this meta-package:
    • urdf: One of the important packages inside the robot_model meta package is urdf. The URDF package contains a C++ parser for the Unified Robot Description Format (URDF), which is an XML file to represent a robot model.
  • We can define a robot model, sensors, and a working environment using URDF and can parse it using URDF parsers. We can only describe a robot in URDF that has a tree-like structure in its links, that is, the robot will have rigid links and will be connected using joints. Flexible links can't be represented using URDF. The URDF is composed using special XML tags and we...

Understanding robot modeling using URDF

We have discussed the urdf package. In this section, we will look further at the URDF XML tags, which help to model the robot. We have to create a file and write the relationship between each link and joint in the robot and save the file with the .urdf extension.

The URDF can represent the kinematic and dynamic description of the robot, visual representation of the robot, and the collision model of the robot.

The following tags are the commonly used URDF tags to compose a URDF robot model:

  • link: The link tag represents a single link of a robot. Using this tag, we can model a robot link and its properties. The modeling includes size, shape, color, and can even import a 3D mesh to represent the robot link. We can also provide dynamic properties of the link such as inertial matrix and collision properties.

    The syntax is as follows:

    <link name="<name of the link>">
    <inertial>...........</inertial>
      <visual> ..........

Creating the ROS package for the robot description

Before creating the URDF file for the robot, let's create a ROS package in the catkin workspace so that the robot model keeps using the following command:

$ catkin_create_pkg mastering_ros_robot_description_pkg roscpp tf geometry_msgs urdf rviz xacro 

The package mainly depends on the urdf and xacro packages, and we can create the urdf file of the robot inside this package and create launch files to display the created urdf in RViz. The full package is available on the following Git repository, you can clone the repository for a reference to implement this package or you can get the package from the book's source code:

$ git clone https://github.com/qboticslabs/mastering_ros_robot_description_pkg.git

Before creating the urdf file for this robot, let's create three folders called urdf, meshes, and launch inside the package folder. The urdf folder can be used to keep the urdf/xacro files that we are going to create. The meshes...

Creating our first URDF model

After learning about URDF and its important tags, we can start some basic modeling using URDF. The first robot mechanism that we are going to design is a pan and tilt mechanism as shown in the following figure.

There are three links and two joints in this mechanism. The base link is static, in which all other links are mounted. The first joint can pan on its axis and the second link is mounted on the first link and it can tilt on its axis. The two joints in this system are of a revolute type.

Creating our first URDF model

Figure 4 : Visualization of a pan and tilt mechanism in RViz

Let's see the URDF code of this mechanism. Navigate to chapter_2_code/mastering_ros_robot_description_pkg/urdf and open pan_tilt.urdf. The code indentation in URDF is not mandatory for URDF but it keeping indentation can improve code readability:

<?xml version="1.0"?>
<robot name="pan_tilt">

  <link name="base_link">
    <visual>
      <geometry>
...

Explaining the URDF file

When we check the code, we can add a <robot> tag at the top of the description:

<?xml version="1.0"?>
<robot name="pan_tilt">

The <robot> tag defines the name of the robot that we are going to create. Here, we named the robot pan_tilt.

If we check the sections after the <robot> tag definition, we can see link and joint definitions of the pan and tilt mechanism:

  <link name="base_link">
    <visual>
      <geometry>
      <cylinder length="0.01" radius="0.2"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="yellow">
        <color rgba="1 1 0 1"/>
      </material>
    </visual>
  </link>

The preceding code snippet is the base_link definition of the pan and tilt mechanism. The <visual> tag can describe the visual appearance of the link, which is shown...

ROS packages for robot modeling


ROS provides some good packages that can be used to build 3D robot models. In this section, we will discuss some of the important ROS packages that are commonly used to build robot models:

  • robot_model: ROS has a meta package called robot_model, which contains important packages that help build the 3D robot models. We can see all the important packages inside this meta-package:

    • urdf: One of the important packages inside the robot_model meta package is urdf. The URDF package contains a C++ parser for the Unified Robot Description Format (URDF), which is an XML file to represent a robot model.

  • We can define a robot model, sensors, and a working environment using URDF and can parse it using URDF parsers. We can only describe a robot in URDF that has a tree-like structure in its links, that is, the robot will have rigid links and will be connected using joints. Flexible links can't be represented using URDF. The URDF is composed using special XML tags and we can...

Understanding robot modeling using URDF


We have discussed the urdf package. In this section, we will look further at the URDF XML tags, which help to model the robot. We have to create a file and write the relationship between each link and joint in the robot and save the file with the .urdf extension.

The URDF can represent the kinematic and dynamic description of the robot, visual representation of the robot, and the collision model of the robot.

The following tags are the commonly used URDF tags to compose a URDF robot model:

  • link: The link tag represents a single link of a robot. Using this tag, we can model a robot link and its properties. The modeling includes size, shape, color, and can even import a 3D mesh to represent the robot link. We can also provide dynamic properties of the link such as inertial matrix and collision properties.

    The syntax is as follows:

    <link name="<name of the link>">
    <inertial>...........</inertial>
      <visual> ............</visual...

Creating the ROS package for the robot description


Before creating the URDF file for the robot, let's create a ROS package in the catkin workspace so that the robot model keeps using the following command:

$ catkin_create_pkg mastering_ros_robot_description_pkg roscpp tf geometry_msgs urdf rviz xacro 

The package mainly depends on the urdf and xacro packages, and we can create the urdf file of the robot inside this package and create launch files to display the created urdf in RViz. The full package is available on the following Git repository, you can clone the repository for a reference to implement this package or you can get the package from the book's source code:

$ git clone https://github.com/qboticslabs/mastering_ros_robot_description_pkg.git

Before creating the urdf file for this robot, let's create three folders called urdf, meshes, and launch inside the package folder. The urdf folder can be used to keep the urdf/xacro files that we are going to create. The meshes folder keeps...

Creating our first URDF model


After learning about URDF and its important tags, we can start some basic modeling using URDF. The first robot mechanism that we are going to design is a pan and tilt mechanism as shown in the following figure.

There are three links and two joints in this mechanism. The base link is static, in which all other links are mounted. The first joint can pan on its axis and the second link is mounted on the first link and it can tilt on its axis. The two joints in this system are of a revolute type.

Figure 4 : Visualization of a pan and tilt mechanism in RViz

Let's see the URDF code of this mechanism. Navigate to chapter_2_code/mastering_ros_robot_description_pkg/urdf and open pan_tilt.urdf. The code indentation in URDF is not mandatory for URDF but it keeping indentation can improve code readability:

<?xml version="1.0"?>
<robot name="pan_tilt">

  <link name="base_link">
    <visual>
      <geometry>
      <cylinder length="0.01" radius...

Explaining the URDF file


When we check the code, we can add a <robot> tag at the top of the description:

<?xml version="1.0"?>
<robot name="pan_tilt">

The <robot> tag defines the name of the robot that we are going to create. Here, we named the robot pan_tilt.

If we check the sections after the <robot> tag definition, we can see link and joint definitions of the pan and tilt mechanism:

  <link name="base_link">
    <visual>
      <geometry>
      <cylinder length="0.01" radius="0.2"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="yellow">
        <color rgba="1 1 0 1"/>
      </material>
    </visual>
  </link>

The preceding code snippet is the base_link definition of the pan and tilt mechanism. The <visual> tag can describe the visual appearance of the link, which is shown on the robot simulation. We can define the link geometry (cylinder, box, sphere, or mesh...

Visualizing the robot 3D model in RViz


After designing URDF, we can view it on RViz. We can create a view_demo.launch launch file and put the following code into the launch folder. Navigate to chapter_2_code/mastering_ros_robot_description_pkg/launch for the same code:

<launch>
  <arg name="model" />
  <param name="robot_description" textfile="$(find mastering_ros_robot_description_pkg)/urdf/pan_tilt.urdf" />
  <param name="use_gui" value="true"/>

  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find mastering_ros_robot_description_pkg)/urdf.rviz" required="true" />

</launch>

We can launch the model using the following command:

$ roslaunch mastering_ros_robot_description_pkg view_demo.launch

If everything works fine, we will get a pan and tilt mechanism...

Adding physical and collision properties to a URDF model


Before simulating a robot in a robot simulator, such as Gazebo, V-REP, and so on, we need to define the robot link's physical properties such as geometry, color, mass, and inertia, and the collision properties of the link.

We will only get good simulation results if we define all these properties inside the robot model. URDF provides tags to include all these parameters and code snippets of base_link contained in theses properties as given here:

<link>
......    
<collision>
      <geometry>
      <cylinder length="0.03" radius="0.2"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
    </collision>

    <inertial>
    <mass value="1"/>
    <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
...........
</link>

Here, we define the collision geometry as cylinder and the mass as 1 Kg, and we also set the inertial matrix of...

Understanding robot modeling using xacro


The flexibility of URDF reduces when we work with complex robot models. Some of the main features that URDF is missing are the simplicity, reusability, modularity, and programmability.

If someone wants to reuse a URDF block ten times in his robot description, he can copy and paste the block ten times. If there is an option to use this code block and make multiple copies with different settings, it will be very useful while creating the robot description.

The URDF is single file and we can't include other URDF files inside it. This reduces the modular nature of the code. All code should be in a single file, which reduces the code simplicity too.

Also, if there is some programmability, such as adding variable, constants, mathematical expressions, conditional statement, and so on, in the description language, it will be more user friendly.

The robot modeling using xacro meets all these conditions and some of the main features of xacro are as follows:

  • Simplify...

Conversion of xacro to URDF


After designing the xacro file, we can use the following command to convert it into a UDRF file:

$ rosrun xacro xacro.py pan_tilt.xacro > pan_tilt_generated.urdf

We can use the following line in the ROS launch file for converting xacro to UDRF and use it as a robot_description parameter:

  <param name="robot_description" command="$(find xacro)/xacro.py $(find mastering_ros_robot_description_pkg)/urdf/pan_tilt.xacro" />

We can view the xacro of pan and tilt by making a launch file, and it can be launched using the following command:

$ roslaunch mastering_ros_robot_description_pkg view_pan_tilt_xacro.launch
Left arrow icon Right arrow icon

Key benefits

  • • Develop complex robotic applications using ROS for interfacing robot manipulators and mobile robots with the help of high end robotic sensors
  • • Gain insights into autonomous navigation in mobile robot and motion planning in robot manipulators
  • • Discover the best practices and troubleshooting solutions everyone needs when working on ROS

Description

The area of robotics is gaining huge momentum among corporate people, researchers, hobbyists, and students. The major challenge in robotics is its controlling software. The Robot Operating System (ROS) is a modular software platform to develop generic robotic applications. This book discusses the advanced concepts in robotics and how to program using ROS. It starts with deep overview of the ROS framework, which will give you a clear idea of how ROS really works. During the course of the book, you will learn how to build models of complex robots, and simulate and interface the robot using the ROS MoveIt motion planning library and ROS navigation stacks. After discussing robot manipulation and navigation in robots, you will get to grips with the interfacing I/O boards, sensors, and actuators of ROS. One of the essential ingredients of robots are vision sensors, and an entire chapter is dedicated to the vision sensor, its interfacing in ROS, and its programming. You will discuss the hardware interfacing and simulation of complex robot to ROS and ROS Industrial (Package used for interfacing industrial robots). Finally, you will get to know the best practices to follow when programming using ROS.

Who is this book for?

If you are a robotics enthusiast or researcher who wants 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 will also be good for programmers who want to explore the advanced features of ROS.

What you will learn

  • •Create a robot model of a Seven-DOF robotic arm and a differential wheeled mobile robot
  • • Work with motion planning of a Seven-DOF arm using MoveIt!
  • • Implement autonomous navigation in differential drive robots using SLAM and AMCL packages in ROS
  • • Dig deep into the ROS Pluginlib, ROS nodelets, and Gazebo plugins
  • • Interface I/O boards such as Arduino, Robot sensors, and High end actuators with ROS
  • • Simulation and motion planning of ABB and Universal arm using ROS Industrial
  • • Explore the ROS framework using its latest version

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 21, 2015
Length: 480 pages
Edition : 1st
Language : English
ISBN-13 : 9781785282997
Category :
Languages :
Concepts :

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 : Dec 21, 2015
Length: 480 pages
Edition : 1st
Language : English
ISBN-13 : 9781785282997
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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 Can$6 each
Feature tick icon Exclusive print discounts
$279.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 Can$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Can$ 217.97
Mastering ROS for Robotics Programming
Can$77.99
ROS Robotics By Example
Can$69.99
Learning ROS for Robotics Programming Second Edition
Can$69.99
Total Can$ 217.97 Stars icon
Banner background image

Table of Contents

13 Chapters
1. Introduction to ROS and Its Package Management Chevron down icon Chevron up icon
2. Working with 3D Robot Modeling in ROS Chevron down icon Chevron up icon
3. Simulating Robots Using ROS and Gazebo Chevron down icon Chevron up icon
4. Using the ROS MoveIt! and Navigation Stack Chevron down icon Chevron up icon
5. Working with Pluginlib, Nodelets, and Gazebo Plugins Chevron down icon Chevron up icon
6. Writing ROS Controllers and Visualization Plugins Chevron down icon Chevron up icon
7. Interfacing I/O Boards, Sensors, and Actuators to ROS Chevron down icon Chevron up icon
8. Programming Vision Sensors using ROS, Open-CV, and PCL Chevron down icon Chevron up icon
9. Building and Interfacing Differential Drive Mobile Robot Hardware in ROS Chevron down icon Chevron up icon
10. Exploring the Advanced Capabilities of ROS-MoveIt! Chevron down icon Chevron up icon
11. ROS for Industrial Robots Chevron down icon Chevron up icon
12. Troubleshooting and Best Practices in ROS Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(10 Ratings)
5 star 40%
4 star 30%
3 star 20%
2 star 10%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Lloyd F. Mar 29, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Good covers Indigo an Jade, unlike the OSRF book, which was outdated by the time it got to press.
Amazon Verified review Amazon
Neil John Feb 01, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book contain detail description about R.O.S and its new features !!Really loved it !!
Amazon Verified review Amazon
Cattaneo A. Apr 09, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Proprio quello che volevo, spiega tt di ros e delle nuove funzioni, per capirloServe una base di c e dell'ambiente Linux , cosigliato per chi come me sta' preparando laTesi in ing. robotica
Amazon Verified review Amazon
Amazon Customer Dec 21, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Nicely and quick delivery. Decently packed in a compact recipient so that it fits the mailbox.Very good and detailed book, however not for a novice.
Amazon Verified review Amazon
Bukworm Mar 29, 2017
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Nicely written book!
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.