Introduction to ROS 2
local graph
Chapter 1 — Introduction to ROS 2
Section titled “Chapter 1 — 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 robots efficiently. The ROS framework is widely used in academia and industry to model, simulate, and develop different robotics applications. This is an introductory chapter that gives you a general overview of this framework. This chapter will be useful for people who already know ROS and those who are just starting with ROS as well.
In this chapter, we’re going to cover the following main topics:
- ROS as a framework for robotics
- Important features of ROS
- Comparison of ROS 1 and ROS 2
- Communication stack in ROS 2
- DDS vendors in ROS 2
Understanding ROS as a robotics framework
Section titled “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 question: What is ROS?
What is ROS?
Section titled “What is ROS?”Contrary to what the name might suggest, ROS is not a real Operating System (OS) like Windows, Linux, and macOS. It has some OS-like functionalities, but it is not a real OS. ROS is an open-source framework designed to develop robot software applications. It provides a set of robot-specific libraries, software tools, and implementation of the robot’s high-level capabilities.
ROS provides robot software in packages, and developers can create and reuse existing packages. Each package can contain the implementation of different algorithms, datasets, robot configuration files, robot models, etc.
There are two main versions of ROS: ROS 1 and ROS 2. ROS 1 is a legacy version, and ROS 2 is the latest one. ROS 1 is fully supported on Linux-based OSs, while ROS 2 is compatible with Windows, Linux, and macOS. This book is completely focused on ROS 2. Figure 1.1 shows the logo of the ROS framework.

Figure 1.1: ROS logo
Figure 1.1: ROS logo
The official ROS website can be found at [1]. Open Robotics [2] develops and maintains the ROS project. They work with the global ROS community of developers, academic researchers, and industry professionals to accelerate ROS package development. Using ROS, we can develop almost all the software components of a robot.
Important features of ROS
Section titled “Important features of ROS”Here is a list of important features of ROS:
- Inter-Process Communication (IPC) Infrastructure: Programming robots simply means creating different applications in the robot computer to accomplish different tasks. The computer might have some OS like Ubuntu/Linux installed. The robot’s sensors and actuators are connected to this computer via USB or other interfaces. We may have to write multiple ROS programs, also called ROS nodes, in the OS to acquire and process data from sensors and send control commands to the actuator. Developing a single program that handles all the tasks of the robot will not be a good idea for programming a robot because it adds more complexity to the program and makes debugging difficult. That is where ROS comes into the picture. The ROS libraries provide different APIs to communicate between these programs, which are running on OS. In that way, we can run multiple ROS nodes in the OS that communicate with each other to accomplish the entire robot’s operations. This IPC infrastructure is the most important feature of ROS 1 and ROS 2. The IPC infrastructure in ROS 2 differs from that in ROS 1. ROS 2 uses the latest and most reliable software components for communication, which will improve the robot’s overall performance.
- Reusability and Modularity: The software developed by others can easily be reused in our applications. This is one of the most useful features of ROS because it avoids reinventing the wheel and saves development time. The ROS packages are designed to be modular and there are more than 10,000 packages in ROS contributed by Open Robotics and the ROS community. Each package serves one or more purposes. We can reuse any of these packages in our robot software stack and significantly reduce the development time. For example, if we need to combine a list of laser scans from the robot, we can use the
laser_scan_merger[3] package and integrate it into our robot application. - Open-Source License: ROS 1 and ROS 2 software mainly comes with a Berkeley Software Distribution (BSD) 3-Clause license; with this license, we can modify and redistribute our robotics application for commercial purposes. The BSD licensing enables a high degree of flexibility. Not all packages come with a BSD 3-Clause license; some packages are the Apache 2.0 License, the MIT License, or the Lesser General Public License (LGPL), depending on the contributions from different developers and the specific requirements of the software components. It’s always a good idea to check the individual package licenses for specific details.
- Tools and Libraries: ROS comes with a set of software tools. What are ROS tools? ROS tools help developers visualize different types of sensor data sent and received by ROS nodes. Another important use case is debugging, as multiple ROS programs/nodes may communicate with each other and there can be different issues in the communications. These issues can be debugged using ROS tools. The ROS libraries are designed for specific purposes. The client libraries in ROS help the ROS nodes to communicate with each other. We can use the rclcpp library to write ROS 2 C++ nodes and rclpy for Python nodes. Libraries like TF (Transformation) in ROS help developers keep the transformation of each link and joint of the robot. There are multiple libraries in ROS, which will accelerate the robot software development time. We will see some examples of ROS tools in the next section.
- Hardware Abstraction: A ROS driver for a robot is a set of nodes that help developers interact with different hardware components like actuators, sensors, or an embedded platform. ROS provides a hardware abstraction, which means that if hardware components change, developers can easily integrate them into the robot. ROS provides a standard interface for developing hardware drivers, so replacing robot components becomes easier.
- Ready-to-Use Robot Capabilities: This is the main reason why ROS has become highly popular. ROS provides a ready-to-use template for the implementation of high-level tasks like autonomous navigation, manipulation, and perception. Developers can use this template for their robots and customize it for their applications.
- Cross-Platform Support: Mostly, the OS in robots is powered by Linux-based distros like Ubuntu, but any OS, like Windows, macOS, Android, etc, can be used. Cross-platform support is an important feature in ROS in which developers can create ROS packages and deploy them on multiple OS platforms. ROS 1 was mainly supported for Linux distributions like Ubuntu, whereas ROS 2 supports Ubuntu Linux, Windows 10, and macOS.
- Middleware Independence: One of the core components of ROS is the communication middleware. So, what is the communication middleware for? We already discussed that ROS provides APIs to communicate between different nodes. Underlying the API is a communication layer, which facilitates communication. The middleware is the intermediate layer that exists between the user applications and the OS. In ROS 1, there was only one fixed middleware for communication, but in ROS 2, that changed. In ROS 2, we have a pluggable middleware infrastructure like Data Distribution Service (DDS) or Zero Overhead Network Protocol (Zenoh). We can change the middleware based on the application we are dealing with. We will look at DDS in more detail in the upcoming section. Some examples of DDS are Fast DDS, Cyclone DDS, and RTI Connext.
- Community and Ecosystem: Compared to other robotics software frameworks, the ROS community is huge. Most of the packages in ROS are contributed to and maintained by developers across the globe. These packages can be reused and reduce overall development time. There are not only packages but also forums and blogs to support new ROS developers. ROSCon [4] is the annual event where the community meets to share innovations in the ROS framework.
- Testing and Simulation: ROS comes with a testing framework and simulation tools to validate the robot application before deployment. Multiple robot simulators, such as Gazebo, Webots, and Isaac Sim, support ROS 1 and ROS 2.
- Production-Ready Framework: One of the most asked questions when developing robot applications with ROS is whether they are production ready. ROS 1 was designed for robotic research applications. However, this is not the case for ROS 2. It is designed to be used in production. It uses much-improved architecture compared to ROS 1, and we can use ROS 2 in many use cases, such as the automation industry, healthcare, autonomous vehicles, etc.
We have seen some of the important features of ROS. Now, let’s have a look at the ROS equation.
ROS equation
Section titled “ROS equation”The ROS equation depicts the important components within the ROS framework. The important elements of ROS are shown in Figure 1.2.
![Figure 1.2: ROS equation (source: Open Robotics [5] | https://www.ros.org/imgs/ros-equation.png)](https://static.packt-cdn.com/products/9781836209010/graphics/Images/B31503_01_2.png)
Figure 1.2: ROS equation (source: Open Robotics [5] | https://www.ros.org/imgs/ros-equation.png)
Figure 1.2: ROS equation (source: Open Robotics [5] | https://www.ros.org/imgs/ros-equation.png)
The important components of ROS 1 and ROS 2 are as follows:
- Plumbing: The term plumbing refers to IPC, which is facilitated by ROS communication middleware. In ROS 1, the communication between nodes uses TCPROS (a TCP-based protocol), whereas in ROS 2, it uses DDS.
- Tools: There are GUI tools and command-line tools in ROS. The main examples of GUI tools in ROS are the ROS Visualizer (RViz) [6] and rqt [7]. These tools can be used to visualize the data exchange between ROS nodes and for debugging communication between nodes. The command-line tools can be invoked from the Linux shell.
- Capabilities: The important capabilities of ROS are navigation, manipulation, and perception. In ROS 2, the robot navigation is implemented as an open-source project called Nav2 [8], and the robot manipulation is implemented as an open-source project called MoveIt [9]. The perception stack in ROS has tight integration with popular perception libraries like OpenCV [10], Point Cloud Library (PCL) [11], BT.CPP [4], and Open3D [12].
- Community: ROS has a big, active, open-source community. There is a list of community-contributed packages and libraries in ROS [13], which includes Nav2 and MoveIt 2. There is a ROS community engagement platform hosted on Discourse [14]. We can get the latest updates here. Also, there is Robotics Stack Exchange website to solve your ROS issues [15]. There is ROS Discord for real-time communication [16]. This strong community is the backbone of the ROS framework.
The following section details the ROS project development time, giving insight into its evolution.
ROS development timeline
Section titled “ROS development timeline”So far, we have reviewed the main features of ROS and the ROS equation. Now, let’s have a quick look at ROS evolution. When did this project start, and what is the latest version of ROS?
- 2007: ROS development began in 2007 at the Stanford Artificial Intelligence Laboratory and was later continued and significantly expanded by Willow Garage. [17].
- 2008: An early version of ROS (0.4, Mango Tango) is released by Willow Garage.
- 2010: The first official ROS 1.0 distribution of ROS, Box Turtle, is released. In the same year, ROS C Turtle is released.
- 2011: ROS Diamondback and Electric Emys are released.
- 2012: ROS Fuerte and Groovy are released.
- 2013: ROS Hydro Medusa is released, which includes major updates to packages and documentation.
- 2014: ROS Indigo is released. After Hydro, ROS began to be developed and maintained by the Open Source Robotics Foundation (OSRF). Their first release was Indigo.
- 2015: ROS Jade Turtle is released.
- 2016: ROS Kinetic Kame is released.
- 2017: ROS Lunar Loggerhead is released; in the same year, the first ROS 2 distribution is released: ROS Ardent Apalone. ROS 2 is a separate project from the legacy ROS 1, with many components redesigned and reimplemented to address ROS 1’s limitations.
- 2018: ROS 1.0 Melodic Morenia and ROS 2 Bouncy Bolson are released.
- 2019: ROS 2 Dashing and Eloquent are released.
- 2020: ROS 1.0 Noetic Ninjemys and ROS 2 Foxy Fitzroy are released. ROS 1.0 Noetic Ninjemys is the final distribution of ROS 1.0. It will be supported until 2025.
- 2021: ROS 2.0 Galactic is released.
- 2022: ROS 2.0 Humble Hawksbill is released.
- 2023: ROS 2.0 Iron Irwini is released.
- 2024: ROS 2.0 Jazzy Jalisco is released. The End of Life (EOL) of this distribution is 2029. This is the distribution we are using in this book.
- 2025: ROS 2.0 Kilted Kaiju is released.
Here is a link to the ROS 1 distribution [18] and the ROS 2 distribution [19].
Now that you have an overview of the ROS framework, let’s compare its two versions.
Comparing ROS 1 and ROS 2 architecture
Section titled “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
Section titled “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
Section titled “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 the core middleware components like TCP ROS/UDP ROS and the Nodelet API. The middleware layer of ROS 1 is custom-built and distributed along with ROS. In ROS 2, the communication middleware is DDS. DDS is a protocol implemented in different libraries by different vendors. ROS 2 developers use these implementations. DDS is already used to develop production-grade IPC-based software for autonomous robots, aerospace, and defense. ROS 2 is built upon DDS implementations. Examples of popular DDS implementations are Fast DDS, Cyclone DDS, and RTI Connext [20].
In the ROS 1 middleware layer, we can see the Nodelet API section, which is used for implementing intra-process communication in ROS nodes. Intra-process communication differs from inter-process communication. In intra-process communication, data is exchanged between different parts of a single process, like threads, modules, etc., by sharing memory space. It allows fast and efficient data transfer, whereas IPC is data exchange between different processes. Nodelet in ROS 1 offers significant performance benefits, such as zero-copy data transfer, reduced CPU load from avoiding serialization, lower memory usage by preventing data duplication, and faster, low-latency communication that improves throughput for high-frequency data like images or point clouds.
The client libraries in ROS 1 and ROS 2 provide APIs for communicating between different nodes in ROS. The nodes can be implemented in different programming languages, such as C++, Python, Java, etc. There are separate client libraries for each programming language. For example, roscpp is a client library for C++, and rospy is a client library for Python in ROS 1, whereas rclcpp and rclpy are the client libraries of C++ and Python in ROS 2. In ROS 2, all client libraries are built on top of the ROS Client Library (RCL), a core client library in ROS 2. The RCL implements ROS 2 concepts and other programming languages can use this API and wrap it and use. It avoids the need to build client libraries from scratch, making the development of client libraries easier and more efficient.
Like the Nodelet API in ROS 1, there is an intra-process API in ROS 2, which has the same purpose. In ROS 2, there is a new layer connecting DDS and client libraries, called the abstract DDS layer or ROS Middleware (RMW). This layer is not only for DDS but also applicable to other communication protocols like Eclipse Zenoh. This layer decouples the ROS 2 core libraries from DDS and other protocols. This design enables us to change the DDS at any time. In short, the abstract DDS layer acts as an interface between the ROS 2 API and various DDS or other middleware implementations. This design approach in ROS 2 gives developers more flexibility and modularity.
Application layer
Section titled “Application layer”The application layer is where developers can create different robotic applications by using ROS APIs in the client library. We can write different ROS nodes that can communicate with each other. If you look at the ROS 1 architecture, you will find a node called master in the application layer. The master node comes with ROS 1 installation, and it is basically a broker program. With the help of this broker program, ROS 1 nodes can discover other nodes and communicate with each other. So, we must run the master node in the OS before starting any ROS 1 node. If the master node fails to run, it will affect the complete ROS 1 application running on the robot. This is a major issue, and it was fixed in ROS 2.
If you check on the ROS 2 side, there is no master node, but the nodes can communicate as well. This is a major change in ROS 2, which uses DDS as middleware. In ROS 2, developers can write nodes, and nodes can make discoveries using DDS and start communication.
Feature comparison between ROS 1 and ROS 2
Section titled “Feature comparison between ROS 1 and ROS 2”Here is an important feature comparison between ROS 1 and ROS 2.
| Features | ROS 1 | ROS 2 |
|---|---|---|
| Communication Middleware | Custom TCP-based communication middleware. The master node is for node registration and lookup, which can be a single point of failure. | Use DDS and communication protocols like Zenoh. |
| Real-Time | Not designed for real-time processing, but it can be tweaked with significant effort. | We can make real-time applications with a bit of tweaking and effort. |
| Security | Lack of built-in security features, less suitable for sensitive or critical applications. | Built-in security features through DDS security, which offers authentication, encryption, and access control, make it suitable for industrial and commercial applications. |
| Modularity and Scalability | Highly modular and compatible with multiple programming languages. | Enhanced modularity, compatibility with multiple programming languages, and more flexibility for different development needs. |
| Platform Support | Primary support in Linux-based OS. | Multiple OS support like Windows, Linux, and macOS. |
| Community and Ecosystem | Vast and established community with extensive libraries and tools. Widely used in academic research. | Rapidly growing community. Community shifting from ROS 1 to ROS 2 because of the architectural drawbacks of ROS 1. |
Table 1.1: Comparison between ROS 1 and ROS 2
Next, let’s understand why we should migrate from ROS 1 to ROS 2.
Why should you migrate from ROS 1 to ROS 2?
Section titled “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 security, robustness, and the ability to orchestrate complex robotics tasks.
- When comparing the features, ROS 2 leads all the way. If you consider the security, real-time, Quality of Service (QoS), and scalability aspects of ROS 2, it is far better than ROS 1.
- ROS 1 was platform-specific and mainly compatible with the Linux OS. There are ROS 1 ported versions for Windows and macOS, but they are not stable and maintained. On the other hand, ROS 2 is cross-platform, which makes it ideal for robot application development on Windows and macOS platforms.
- If you are already a ROS 1 developer, the learning curve to migrate to ROS 2 is very low. The communication concepts are the same, but changes are mainly at the API level. We must replace ROS 1 nodes with ROS 2 APIs. This can take some time, but the migration is relatively easy compared to a beginner in ROS 2 because of the common concepts in both. There are new complex concepts in ROS 2 that can take more time to understand, but generally, ROS 1 knowledge will help you to get started with ROS 2 and start developing.
We have discussed why we need to migrate from ROS 1 to ROS 2. Now, let’s explore the core concepts of ROS 2.
Diving into DDS in ROS 2
Section titled “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?
Section titled “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 developed their middleware solution. These companies needed their applications to be interoperable and compatible with other middleware.
DDS has various use cases, like:
- Aerospace and Defense: Used in command-and-control systems and also for real-time communication in UAV (short for unmanned aerial vehicle).
- Healthcare: Used in patient monitoring systems, health information systems, etc.
- Transportation: Autonomous vehicle and railway signaling and control systems.
- Finance: High-frequency trading systems and market data distribution.
- Robotics: Autonomous robots and industrial robots.
There are many such use cases for DDS. The following link shows which organizations use DDS in their products: https://www.dds-foundation.org/who-is-using-dds-2/.
Components DDS standard
Section titled “Components DDS standard”Figure 1.4 shows a block diagram of different components of DDS.

Figure 1.4: Components of the DDS standard (source: RTI | https://www.rti.com/products/dds-standard)
Figure 1.4: Components of the DDS standard (source: RTI | https://www.rti.com/products/dds-standard)
We can see three main layers: platform, middleware, and application. The following are explanations of each layer.
Platform layer
Section titled “Platform layer”This is the bottom layer in the DDS standard diagram. It consists of the OS, network protocols, and network interfaces like Ethernet. We must install the DDS implementation in an OS and configure the network protocol and interface to make it work. We can say that the platform layer is the foundation for DDS to work. Here is a brief idea of other components in the platform layer:
- Internet Protocol (IP): This is the set of network layer protocols or rules for routing data to reach the correct destination [23].
- Transport Protocols: This is the layer just above the IP layer, which helps applications communicate with each other without directly interacting with the IP layer. DDS uses different types of transport protocols in different scenarios.
- Transmission Control Protocol (TCP): DDS uses TCP in situations where reliable communication and ordered message delivery is essential.
- User Datagram Protocol (UDP): DDS uses UDP for minimal latency applications and real-time systems, such as those in robotics, aerospace, and defense. It is often preferred when the timely delivery of the message is more important than reliability.
- Transport Layer Security (TLS): This is for secure TCP communication.
- Time Sensitive Networking (TSN): This is for real-time communication.
- Shared Memory: This is for high-speed data transfer within the same machine. It is useful when the DDS participants (publisher and subscriber) are running on the same machine, and allows lower latency and higher throughput.
The next layer is the middleware layer, which consists of DDS standard implementations. We will discuss a few components of the middleware layer.
Middleware layer
Section titled “Middleware layer”This layer consists of core DDS protocols and their implementation in different programming languages. Here are the core sections in the middleware:
- Real-Time Publish-Subscribe (RTPS): This is the bottom layer in DDS, which ensures interoperability or compatibility across other DDS implementations over the network by using standard protocols. RTPS is part of this standard. This protocol is mainly designed for real-time systems, which can be used for critical applications like robotics, defense systems, etc.
- DDS: This layer manages the distribution of data using the publish/subscribe method. This layer ensures the publishers who send the data and subscribers who receive the data can communicate in a decoupled manner. Here are the key features of DDS:
- Data-Centric Publish/Subscribe Model: As we mentioned above, DDS uses a publish/subscribe communication model, which decouples the publisher and subscribers. This model allows flexible and scalable data distribution.
- QoS Policies: DDS provides many QoS policies that can be easily configured, thereby configuring the behavior of data exchange. Using QoS policies in DDS, we can control the reliability, durability, latency, and resource usage of communication.
- Interoperability: DDS is designed to be platform-independent, allowing us to use it with different OSs and hardware platforms. The APIs provided by DDS implementations are standardized, ensuring interoperability between different DDS implementations and facilitating integration with current systems.
- Real-Time Communication: DDS is optimized for real-time communication by providing low-latency and high-throughput data exchange. It also delivers deterministic data delivery, which makes it suitable for time-critical applications.
- Scalability: DDS supports the dynamic discovery of publisher and subscriber nodes, meaning publishers can connect to subscribers automatically and find each other without any configuration. DDS offers scalability because it can accommodate large-scale systems with numerous participants (publishers and subscribers).
- Security: DDS comes with built-in security features such as authentication, encryption, and access control to protect and secure communication.
- Language-Specific Implementations: The publisher and subscriber of DDS can be from any programming language, such as C++, Java, Python, etc. The DDS layer provides supported APIs in these languages for implementing publishers and subscribers. In Figure 1.4, you can see that DDS-C++, DDS-JAVA, etc. provide support to these programming languages. You can also find DDS-IDL-C and DDS-IDL-C#; IDL stands for Interface Definition Language. This helps to define different data types and interfaces for communication between participants. DDS-IDL-C implements an API in C with IDL to define data types for communication.
- Addition DDS Specifications: These are additional specifications of DDS that go hand in hand with the DDS standard:
- DDS-WEB: Integrating web technologies into DDS. - DDS-OPC UA: Compatibility with OPC Unified Architecture, which is a machine-to-machine communication protocol. - DDS-RPC: This enables remote procedure call support in DDS. - DDS-XTYPES: This extends to complex data modeling. - IDL 4: This is the version of IDL used in this DDS architecture, which defines data types. - DDS-Security: This is a set of specifications for ensuring secure data exchange and access control.
- Data-Centric Publish/Subscribe Model: As we mentioned above, DDS uses a publish/subscribe communication model, which decouples the publisher and subscribers. This model allows flexible and scalable data distribution.
In the next section, we can see the application layers in the DDS.
Application layer
Section titled “Application layer”This is where user applications come in. We can use the APIs for different programming languages in DDS to create our own publisher and subscriber programs for different applications.
How DDS works?
Section titled “How DDS works?”In this section, we will examine how DDS works and how the user applications communicate with each other. The following are some of the key concepts we must understand before proceeding.

Figure 1.5: DDS global data space
Figure 1.5: DDS global data space
Figure 1.5 shows various concepts in the DDS architecture. The first concept we will be discussing is Global Data Space (GDS):
- GDS: In DDS, the GDS refers to the virtual shared memory or network where all data exchange between participants (nodes) occurs. This will act like a shared data pool that is accessible to all DDS participants regardless of their location. The GDS is data-centric, meaning it prioritizes the data itself over the applications that use it. This also ensures that the data publishing/subscribing will be decoupled from the application logic.
![Figure 1.6: Example of DDS domain and publisher/subscriber nodes (source: ResearchGate [24] | https://www.researchgate.net/figure/Data-sharing-in-the-global-data-space-in-DDS_fig2_358142403)](https://static.packt-cdn.com/products/9781836209010/graphics/Images/B31503_01_6.png)
Figure 1.6: Example of DDS domain and publisher/subscriber nodes (source: ResearchGate [24] | https://www.researchgate.net/figure/Data-sharing-in-the-global-data-space-in-DDS\_fig2\_358142403)
Figure 1.6: Example of DDS domain and publisher/subscriber nodes (source: ResearchGate [24] | https://www.researchgate.net/figure/Data-sharing-in-the-global-data-space-in-DDS\_fig2\_358142403)
- Domains: A domain in DDS is a logical partition in the GDS. It creates a boundary within which the exchange of data takes place. There can be multiple domains in a GDS. The participants inside the domain can discover each other and easily communicate, but they will be isolated from other domains. Based on the application need, domains help scale, secure, and separate data spaces. In Figure 1.6, we can see an illustration of domains. Multiple robots are communicating on different topics inside the domain.
- Topics: As you can see in Figure 1.5, each domain contains topics. Topics are a named data bus or channel that acts as a bridge between publishers and subscribers. Each topic has a name, a data type, and a set of QoS policies. The data can be published and subscribed using the topic name and it can stream data that is already defined. No other data types can be published through the same topic name. QoS policies ensure data is transmitted reliably within the given parameters. The data type of topics is defined using the IDL format. We will see more about IDL in the next chapter. The publisher and subscriber should agree on this format for exchanging data. Domains can have multiple topics, and there can be many publishers and many subscribers for a single topic.
- Publishers and Subscribers: Applications that use DDS for communication are commonly called domain participants. Applications that send data to a topic are called publishers, and applications that receive data from a topic are called subscribers. Domain participants can be publishers, subscribers, or both. A publisher contains multiple data writers, and a subscriber can have multiple data readers.
- Data Writers and Data Readers: The data writers are components in DDS responsible for writing data on a specific topic. They act as the source of data for a topic, whereas data readers are responsible for reading data from a specific topic. Data writers and readers can be configured using QoS policies to specify the behaviour of data publishing and data subscribing.
- QoS: QoS policies define the behavior of data exchange. We can define the QoS for a topic, publisher, subscriber, data reader, or data writer. These QoS policies help define how the data is being transported. We can assign QoS policies for individual components, or we can assign a set of QoS policies, which are called QoS profiles. We will discuss QoS in more detail in the DDS feature list in the next chapter.
We have discussed how DDS works and seen its important components. In the next section, we can see an example workflow of publish-subscribe using DDS.
Exploring a workflow for sending and receiving data using DDS
Section titled “Exploring a workflow for sending and receiving data using DDS”Now that you understand the basic terminology of DDS, let’s start exploring a workflow for sending and receiving data using DDS. Here is an example of a temperature value getting published and subscribed using DDS.

Figure 1.7: DDS topic-based communication example
Figure 1.7: DDS topic-based communication example
Let’s delve into the workflow:
- Defining the Topic: The first step is to define a topic for a specific application. For example, if we want to send the temperature of a robot body, we can define a topic called Temperature and have a data structure with fields like temperature values, timestamps, and sensor ID.
- Creating a Publisher: In the next step, we can create the publisher node, which can read the sensor data and send it through the topic named Temperature. Before publishing the topic, it is mandatory to configure the domain ID. Using the domain ID, the publisher can understand in which domain it is going to publish the topic. Let’s set the domain ID to 0 here. After setting the domain ID, define the QoS policies for reliable delivery. After the QoS policies, set up the data writer for the Temperature topic. After this, keep on publishing the temperature data.
- Creating a Subscriber: On the subscriber side, we must set the domain ID first and then the QoS settings. After those settings, we can define a data reader for the Temperature topic. Use the data reader to receive the temperature data and do the rest of the processing.
We have seen an example pub-sub workflow using DDS; now, we can see a list of popular DDS vendors and their features.
List of DDS vendors
Section titled “List of DDS vendors”There are commercial DDS vendors and free and open-source vendors. Most commercially available DDS vendors offer enhanced performance, better control, advanced security, support, and certification. Open-source DDS is adapting more to research and education and is being used more in robotics because of ROS 2 integration. Commercial DDS vendors are preferred primarily in mission-critical sectors like defense, aerospace, and medicine. It is also used where more stability, certification, and long-term support are needed.
Here is a list of different implementations of DDS standards by different organizations
- Real-Time Innovations (RTI) [25]:
- Name of DDS: Connext DDS [26].
- Description: Widely used DDS implementation, best known for its high performance and scalability. It supports a wide range of applications from embedded devices to the cloud.
- Core Features: It provides different tools for design, monitoring, and analysis, great documentation and support, and interoperability with other DDS implementations.
- Name of DDS: Connext DDS [26].
- ADLINK Technology [27]:
- Name of DDS: Vortex OpenSplice [28].
- Description: Known for its high performance, reliability, and extensive features like QoS, real-time data propagation, and integration with other DDS implementations. It is widely used in aerospace, defense, industrial automation, etc.
- Core Features: High availability and reliability, support for various programming languages and OSs, extensive QoS.
- Name of DDS: Vortex OpenSplice [28].
- Eclipse Foundation [29]:
- Name of DDS: Eclipse Cyclone DDS [30].
- Description: This is an open-source DDS implementation under the Eclipse Foundation, mainly designed for IoT and edge computing applications.
- Core Features: It is lightweight and efficient, supports multiple OS platforms, and development is driven by the community.
- Name of DDS: Eclipse Cyclone DDS [30].
- Twin Oaks Computing [31]:
- Name of DDS: CoreDX DDS [32].
- Description: This product is suitable for a small-footprint, high-performance DDS implementation, which is suitable for embedded and real-time systems.
- Core Features: It has a small memory footprint, high throughput, and low latency. It supports safety-critical and real-time systems and is interoperable with other DDS implementations. A light version, CoreDX DDS Lite, is available.
- Name of DDS: CoreDX DDS [32].
- eProsima [33]:
- Name of DDS: Fast DDS (formerly Fast RTPS) [34].
- Description: It is an open-source DDS implementation better known for efficiency and performance.
- Core Features: High performance and low latency, open source and community-supported, customizable QoS setting, integration with other protocols via integration service.
- Name of DDS: Fast DDS (formerly Fast RTPS) [34].
- Object Computing, Inc. (OCI) [35]:
- Name of DDS: Open DDS [36]
- Description: An open-source DDS implementation for high performance and data distribution.
- Core Features: Open-source and community-driven, customizable QoS settings, interoperability with other DDS implementations, comprehensive DDS features, extensive documentation and support
- Name of DDS: Open DDS [36]
- Zettascale [37]:
- Name of DDS: Cyclone DDS [38].
- Description: It is an open-source DDS implementation that is designed for reliability and scalability in real-time distributed systems.
- Core Features: Open-source and community-driven, comprehensive QoS settings, suitable for small-footprint and high-performance applications, high throughput and low latency, interoperability with other DDS implementations.
- Name of DDS: Cyclone DDS [38].
We have discussed DDS and its vendors in detail. Now, it’s time to explore the different layers built on top of it.
Dissecting some important ROS 2 layers
Section titled “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)
Section titled “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.
There are different implementations of DDS, like Cyclone DDS, Fast DDS, etc. ROS 2 has interoperability between different DDS, so the ROS 2 nodes should work with any DDS. The RMW layer is the important layer in ROS 2, which enables communication between different ROS 2 nodes, which are independent of underlying middleware (e.g., DDS implementation). It offers flexibility and interoperability and abstracts the communication details of DDS. There are different RMW implementations in ROS 2 for each middleware. We are using DDS by default, but in the future, there may be different RMW implementations for other non-DDS middleware as well.
Here are some popular RMW implementations that support different DDS vendors:
- rmw_fastrtps_cpp: This implementation uses eProsima Fast DDS (formerly Fast RTPS) as the underlying DDS middleware. It is designed for high performance and ease of use. It is used in low-latency and high-throughput applications.
- rmw_cyclonedds_cpp: This implementation uses Eclipse Cyclone DDS, which is mainly used in resource-constrained environments like embedded systems and IoT devices.
- rmw_connextdds_cpp: This implementation uses RTI Connext, a commercial DDS solution known for its robustness and extensive features. It is used in mission-critical applications.
- rmw_opensplice_cpp: This implementation uses ADLINK’s OpenSplice DDS, which offers high scalability and real-time capabilities.
- rmw_zenoh: This is the RMW for ROS 2 that uses Zenoh as the middleware. Zenoh [39] is a lightweight publisher/subscriber protocol that helps different devices and systems to talk to each other, share data, and perform computation efficiently. Zenoh is not DDS, but another protocol that can work as middleware for ROS 2. Zenoh shows comparable performance to DDS in certain scenarios, particularly in bandwidth-constrained environments. The choice of Zenoh or DDS is dependent on specific requirements like network condition, data criticality, and system scalability. This page provides a performance comparison between different publisher/subscriber frameworks available: [40]. The benchmark concludes that Zenoh is the best choice for industrial, IoT, robotics, and automotive applications. Open Robotics selected Zenoh as an alternate middleware to DDS for ROS 2. It may become a popular choice among developers in the future.
- rmw_email: There is even an RMW called rmw_email. It contains a middleware that can send and receive strings over email and has an RMW implementation that allows ROS 2 to use the middleware to exchange messages [44].
We have seen different RMW implementations that connect DDS to the ROS 2 framework, but on top of the RMW implementation, we can see an RCL layer. This layer provides ROS core APIs for writing ROS 2 applications.
Note
We will see the practical implementation of Zenoh as an RMW in Chapter 3.
RCL layer and client libraries
Section titled “RCL layer and client libraries”RCL [41] is an important layer connecting ROS client libraries (like rclcpp for C++, rclpy for Python, and rclc for C) and the underlying RMW layer. The client libraries are for writing ROS nodes in a specific programming language. The primary client libraries in ROS 2 are rclpp, rclpy, and rclc. There are community-maintained client libraries like Node.js, Rust, Dart, and C# [42].
RCL is written in pure C. It provides stable APIs for the client libraries without needing to interact with the lower-level DDS APIs. The C-based API can be wrapped inside different programming languages and extend the ROS 2 programming support to other languages.
ROS 2 application layer
Section titled “ROS 2 application layer”This is the layer where all the ROS 2 nodes and packages come in. A ROS 2 package is a software module that can contain ROS 2 nodes, configuration, data, etc. In the application layer, we can see that many existing packages, tools, and robot capabilities, like navigation, manipulation, and perception stack, have been implemented.

Figure 1.9: ROS 2 DDS connection diagram (source: RTI | https://www.rti.com/products/dds-standard)
Figure 1.9: ROS 2 DDS connection diagram (source: RTI | https://www.rti.com/products/dds-standard)
Figure 1.9 illustrates how DDS connects different modules of ROS 2, like tools, simulators, and capabilities.
In theory, ROS 2 developers can focus entirely on the application layer without worrying much about the underlying DDS implementation. However, in practice, deploying ROS 2 in large-scale networks often requires significant debugging, unlike ROS 1. This has led to a growing interest in alternatives like Zenoh, which was selected last year as an alternative ROS 2 middleware [43].
We have now looked at most of the important aspects of ROS 2 architecture and have gone over the details of DDS, which is the core of ROS 2.
Summary
Section titled “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 chapter also described the evolution of ROS from the Stanford AI Lab, where it was first introduced, to the very latest version, ROS 2 Kilted Kaiju, and discussed migration from ROS 1 to ROS 2. We then went into the details of DDS, the components that compose it, and how it is integrated with ROS 2 to enable scalable and efficient communication in robotic applications.
This chapter provided a foundation for following along with later chapters. In the next chapter, we will discuss the installation of ROS 2 and its detailed concepts.
References
Section titled “References”- [1] https://www.ros.org/
- [2] https://www.openrobotics.org/
- [3] https://www.openrobotics.org/
- [4] https://roscon.ros.org/
- [5] https://www.openrobotics.org/
- [6] https://github.com/ros2/rviz
- [7] https://github.com/ros-visualization/rqt
- [8] https://nav2.org/
- [9] https://moveit.picknik.ai/
- [10] https://opencv.org/
- [11] https://pointclouds.org/
- [12] https://www.open3d.org/
- [13] https://www.ros.org/blog/community/
- [14] https://discourse.ros.org/
- [15] https://robotics.stackexchange.com/
- [16] https://www.ros.org/blog/discord/
- [17] https://www.linkedin.com/company/willow-garage/
- [18] https://wiki.ros.org/Distributions
- [19] https://docs.ros.org/en/jazzy/Releases.html
- [20] https://docs.ros.org/en/jazzy/Installation/DDS-Implementations.html
- [21] https://www.dds-foundation.org/
- [22] https://www.omg.org/
- [23] https://www.cloudflare.com/en-gb/learning/network-layer/internet-protocol/
- [24] https://www.researchgate.net/
- [25] https://www.rti.com/en/
- [26] https://www.rti.com/products
- [27] https://www.adlinktech.com/en/data-distribution-service
- [28] https://www.adlinktech.com/en/vortex-opensplice-data-distribution-service
- [29] https://www.eclipse.org/
- [30] https://projects.eclipse.org/projects/iot.cyclonedds
- [31] https://www.twinoakscomputing.com/
- [32] https://www.twinoakscomputing.com/coredx
- [33] https://www.eprosima.com/
- [34] https://fast-dds.docs.eprosima.com/en/stable/
- [35] https://objectcomputing.com/
- [36] https://objectcomputing.com/platforms/opendds
- [37] https://www.zettascale.tech/
- [38] https://cyclonedds.io/
- [39] https://zenoh.io/
- [40] https://zenoh.io/blog/2023-03-21-zenoh-vs-mqtt-kafka-dds/
- [41] https://github.com/ros2/rcl/
- [42] https://docs.ros.org/en/jazzy/Concepts/Basic/About-Client-Libraries.html
- [43] https://newsroom.eclipse.org/eclipse-newsletter/2023/october/eclipse-zenoh-selected-alternate-ros-2-middleware
- [44] https://github.com/christophebedard/rmw_email
- [45] https://www.behaviortree.dev/