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 2 for Robotics Programming
Mastering ROS 2 for Robotics Programming

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

Arrow left icon
Profile Icon Lentin Joseph Profile Icon Jonathan Cacace
Arrow right icon
$17.98 $29.99
eBook Jul 2025 576 pages 4th Edition
eBook
$17.98 $29.99
Paperback
$25.99 $37.99
Subscription
Free Trial
Arrow left icon
Profile Icon Lentin Joseph Profile Icon Jonathan Cacace
Arrow right icon
$17.98 $29.99
eBook Jul 2025 576 pages 4th Edition
eBook
$17.98 $29.99
Paperback
$25.99 $37.99
Subscription
Free Trial
eBook
$17.98 $29.99
Paperback
$25.99 $37.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 2 for Robotics Programming

Introduction to ROS 2

You might see robots doing tasks like picking and placing objects or moving objects from one point to another. These tasks look simple to us, but they are difficult to accomplish with robots. We humans are powered by a very flexible body and an intelligent brain. However, robots still struggle with limited hardware capabilities and intelligence, which are limited by the instructions we provide in the form of software. It may take years to achieve human-like intelligence and capabilities in robots. As you may know, robots have three main sections: sensors, actuators, and a computer. The computer acts as the brain of the robot, and that is where we load different software applications to perform different tasks. The development of software for robots plays an important role in making the robot intelligent and adaptable for different use cases.

In this chapter, we are going to focus on the Robot Operating System (ROS), a popular software framework for programming...

Understanding ROS as a robotics framework

Developing complex robotics applications from scratch can be a tedious task. Even if we develop it, if our software is not modular and not reusable by others, the same process must be repeated by others, which is like reinventing the wheel. This situation applies not only to robotics but also to other technology domains. That’s why we come across a lot of software frameworks and libraries. These frameworks have ready-made functions or an Application Programming Interface (API) of commonly used algorithms that can be integrated into our program to help us quickly develop our applications.

In robotics software development, we have several software frameworks to create robot applications quickly. One of the popular frameworks available is ROS. Using ROS, we can quickly develop robotics applications by reusing existing code that other developers have already developed. Before jumping into the details, we will start by addressing the...

Comparing ROS 1 and ROS 2 architecture

In this section, we will examine the fundamental architectural changes of ROS 1 and ROS 2 and the important reasons why the ROS 2 project started. Figure 1.3 shows the architecture of ROS 1 and ROS 2.

Figure 1.3: ROS 1 and ROS 2 architecture comparison

Figure 1.3: ROS 1 and ROS 2 architecture comparison

As you can see in Figure 1.3, there are three main layers in both of the architectures. They are:

  • OS Layer
  • Middleware Layer
  • Application Layer

Let’s take a look at each layer in detail.

OS layer

On the left, you can see the architecture of ROS 1, and on the right, ROS 2. The bottom layer is the OS layer. As you know, ROS is a software framework that can be installed on an OS. ROS 1 is mainly compatible with Ubuntu/Linux, whereas ROS 2 is compatible with Linux, Windows, macOS, RTOS, etc.

Middleware layer

The next layer is the middleware layer, which constitutes the main ROS components. If you look at the ROS 1 architecture, it has...

Why should you migrate from ROS 1 to ROS 2?

In this section, we will discuss the important reasons for migrating to ROS 2 from ROS 1. Here, we will not discuss the technical aspects of it but, more generally, why it is better to migrate to ROS 2.

Here are the important points to note:

  • ROS 1 Noetic Ninjemys will reach EOL in 2025. After EOL, we will not have new features, bug fixes, or security updates for the ROS 1 packages. There will not be any ROS 1 versions after this; ROS 1 Noetic is the final official distribution of ROS 1. The primary OS supporting ROS 1 Noetic is Ubuntu 20.04, which is also going to EOL in 2025, so there won’t be any OS updates as well. After 2025, we will only have ROS 2 distributions.
  • ROS 2 can be used in any robotic application, including research and commercial applications. ROS 1 is mainly designed for academic and research use. If you plan to prototype and commercialize a robot, ROS 2 is a good choice because of its enhanced...

Diving into DDS in ROS 2

In this section, we discuss more details about ROS 2’s core module, DDS, which works as the communication middleware for ROS 2, as shown in Figure 1.3.

What is DDS?

DDS [21] is a standard from the Object Management Group (OMG) [22] that was established in 2004 for standard publisher/subscriber communication. It is mainly used in mission-critical applications like air traffic control and management, financial trading, and complex telemetry systems. DDS enables scalable, real-time, dependable, and high-performance data exchange between the publisher and subscriber.

The OMG is a global, open-membership, non-profit consortium responsible for creating and maintaining a number of standards in technical and business domains.

Publisher/subscriber communication involves sending and receiving data. The publisher sends data, and the subscriber listens to and receives it.

The DDS standard mainly came into existence when a group of companies...

Dissecting some important ROS 2 layers

We have gone through the basics of DDS and explored its different features. In this section, we are going to explore the layers in ROS 2 that work on top of DDS. We can start with a detailed discussion of the RMW abstraction layer, which is one of the important layers connecting DDS to the ROS 2 framework.

RMW layer (ROS middleware abstraction interface)

Figure 1.8 shows a detailed architecture of the ROS 2 framework with all its layers.

Figure 1.8: ROS 2 detailed architecture (source: RTI | https://www.slideshare.net/slideshow/deep-dive-into-the-opc-ua-dds-gateway-specification/99648467)

Figure 1.8: ROS 2 detailed architecture (source: RTI | https://www.slideshare.net/slideshow/deep-dive-into-the-opc-ua-dds-gateway-specification/99648467)

We already discussed the DDS framework in Figure 1.2. We learned that DDS has an application layer or APIs that we can use to build our own apps. This is where ROS becomes relevant. The ROS 2 framework is built on top of the DDS API layer. If you take a look at Figure 1.8, you can see that after the DDS framework layer comes the ROS 2 framework...

Summary

This chapter introduced ROS 2, a very popular framework for the development of robotic applications. The chapter provided an overview of the role played by ROS in the provision of modularity and reusability in the platform, allowing developers to quickly create and adapt robotic applications through the reutilization of existing code. It provided an overview of key elements of ROS, including inter-process communication infrastructure, hardware abstraction, licensing under open-source terms, and huge libraries and tools for tasks like visualization, debugging, and communication between different parts of a robot.

It also drew some comparisons between ROS 1 and ROS 2. The latter is more robust because of DDS, has enhanced security features, and is cross-platform compatible. It provides insight into the architectural improvements in ROS 2, focusing on the use of DDS as a communication middleware that can offer flexibility and high performance in real-time applications. The...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Get a solid understanding of ROS 2 core concepts and features from scratch
  • Design, simulate, and prototype robotic applications using ROS 2, C++, Python, and Gazebo
  • Gain hands-on experience with the latest technologies like GenAI and reinforcement learning, integrated with ROS 2 Jazzy
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

The rising demand for advanced robotics software has made proficiency in frameworks like ROS 2 essential for engineers and enthusiasts alike. Lentin Joseph, co-founder of RUNTIME Robotics, and Jonathan Cacace, PhD in robotics, help you grasp the foundational concepts and practical applications in this comprehensive fourth edition updated to cover the latest LTS release from 2024—ROS 2 Jazzy. Starting with a solid introduction to ROS 2, including core components and tools, the chapters get you ready to start programming and using its key features confidently. Building on this, the book focuses on 3D robot modeling and simulation with the new Gazebo Sim, supported by ROS 2 controllers. You’ll explore high-level features such as Nav2 for navigation and MoveIt 2 for manipulation, which are crucial for developing advanced systems. You'll also dive into aerial robotics with ROS 2 and learn how to build real-world robots using Micro-ROS. The concluding chapters cover advanced topics like CI/CD workflows, interfacing ROS 2 with large language model (LLM) agents for intelligent planning, and applying deep reinforcement learning for autonomy. By the end of this book, you'll have a strong foundation in ROS 2, along with the skills needed to build sophisticated, real-world robotic applications.

Who is this book for?

If you are a robotics enthusiast, researcher, or software professional looking to advance your skills in ROS 2, this book is for you. ROS developers who wish to explore the advanced features of ROS 2 will also find this book helpful. Basic knowledge of ROS, GNU/Linux, and C++, as well as Python programming concepts is necessary to get started with this book.

What you will learn

  • Explore ROS 2 architecture, DDS, and communication interfaces in depth
  • Simulate various robots using Gazebo and ROS 2
  • Master Nav2 and MoveIt 2 in ROS 2
  • Explore ros2_control and Perception
  • Build and program a real mobile robot from scratch using Raspberry Pi board and ROS 2
  • Build LLM-based AI agents in ROS 2
  • Implement reinforcement learning applications in ROS 2, NVIDIA Isaac Lab, and Isaac Sim

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 28, 2025
Length: 576 pages
Edition : 4th
Language : English
ISBN-13 : 9781836209003
Category :
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 : Jul 28, 2025
Length: 576 pages
Edition : 4th
Language : English
ISBN-13 : 9781836209003
Category :
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

Table of Contents

21 Chapters
Part I: ROS 2 Programming and Simulation Chevron down icon Chevron up icon
Introduction to ROS 2 Chevron down icon Chevron up icon
Getting Started with ROS 2 Programming Chevron down icon Chevron up icon
Implementing ROS 2 Concepts Chevron down icon Chevron up icon
Working with Robot 3D Modeling in ROS 2 Chevron down icon Chevron up icon
Simulating Robots in a Realistic Environment Chevron down icon Chevron up icon
Part II: ROS 2 Applications: Navigation, Manipulation, and Control Chevron down icon Chevron up icon
Controlling Robots Using the ros2_control Package Chevron down icon Chevron up icon
Implementing ROS 2 Applications Using BehaviorTree.CPP Chevron down icon Chevron up icon
ROS 2 Navigation Stack: Nav2 Chevron down icon Chevron up icon
Robot Manipulation Using MoveIt 2 Chevron down icon Chevron up icon
Working with ROS 2 and Perception Stack Chevron down icon Chevron up icon
Part III: Advanced Applications and Machine Learning Chevron down icon Chevron up icon
Aerial Robotics and ROS 2 Chevron down icon Chevron up icon
Designing and Programming a DIY Mobile Robot from Scratch Chevron down icon Chevron up icon
Testing, Continuous Integration, and Continuous Deployment with ROS 2 Chevron down icon Chevron up icon
Interfacing Large Language Models with ROS 2 Chevron down icon Chevron up icon
ROS 2 and Deep Reinforcement Learning Chevron down icon Chevron up icon
Implementing ROS 2 Visualization and Simulation Plugins Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
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.