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
$19.99 per month
Paperback Jul 2025 576 pages 4th Edition
eBook
$27.98 $39.99
Paperback
$39.98 $49.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Lentin Joseph Profile Icon Jonathan Cacace
Arrow right icon
$19.99 per month
Paperback Jul 2025 576 pages 4th Edition
eBook
$27.98 $39.99
Paperback
$39.98 $49.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$27.98 $39.99
Paperback
$39.98 $49.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781836209010
Category :
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jul 28, 2025
Length: 576 pages
Edition : 4th
Language : English
ISBN-13 : 9781836209010
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 $5 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 $5 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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.

Modal Close icon
Modal Close icon