Basics of Design • CC Blog • Research & Design Hub

Robot Operating System 2 (ROS 2)

Written by Pedro Bertoleti

Core Concepts, Architecture, and Real-World Capabilities

The Robot Operating System 2 (ROS 2) is an open-source, middleware framework that addresses the communication and coordination challenges inherent in modern, distributed robotic systems. In this article, Pedro details how ROS 2’s architectural foundations successfully address the core limitations of its predecessor, ROS 1, using real-world scenarios, and steps for setting up the ROS 2 Foxy environment on Ubuntu Linux distro, and cross-platform communication between a host PC and a Raspberry Pi module.


  • What is ROS 2 and how is it different from ROS 1?
  • How does the publish/subscribe model work in ROS 2?
  • Why is decentralized communication important in robotics systems?
  • What are the real-world applications of ROS 2?
  • How do you install and run ROS 2 Foxy on Ubuntu and Raspberry Pi?
  • Robot Operating System 2 (ROS 2)
  • Ubuntu
  • ROS 2 Foxy
  • Data Distribution Service (DDS)
  • Raspberry Pi
  • Raspberry Pi | raspberrypi.com
  • Canonical | ubuntu.com

The robotics field is getting more and more collective. It is rapidly moving from monolithic, single-unit systems to highly distributed, heterogeneous, and networked configurations. Modern robots, particularly those designed for complex environments such as industrial floors, public roads, or domestic usage, are seldom single entities. Instead, they function as a tightly integrated collection of specialized, communicating modules: sensors, actuators, control systems, and decision-making algorithms, often distributed across multiple microprocessors, single-board computers (SBCs), and even external computational resources.

This paradigm shift necessitates a powerful, flexible, and utterly reliable communication framework to manage the complexity of data flow, synchronization, and inter-process communication (IPC) within the robot, itself, in addition to network communication with other robots or remote control systems over the network. To fulfill these requirements, ROS 2 comes as the state-of-the-art, robust, and a reliable communication solution for robots.

ROS 2 was designed to support modern industrial requirements, including multi-robot coordination—which means two or more robots working together to achieve a common goal.

This article serves as an in-depth technical review of the ROS 2 framework [1]. I will discuss its core components, analyze its sophisticated decentralized architecture, and illustrate its capabilities in creating distributed systems where reliability and performance are paramount. The focus will be on the widely adopted Foxy “flavor,” demonstrating its usage on an Ubuntu Linux distro, including a practical example. (Note: In this context, a “flavor” is the specific installation option or package set you choose. It determines which components and tools are included in your setup, and defines the scope of the installed software.)

WHAT‘S ROS 2?

First of all, it’s important to mention that ROS 2 isn’t an operating system (OS). Rather, it consists of a framework running over an Ubuntu Linux distro. It also can run over other OSes; however, the full compatibility is guaranteed when using Ubuntu distro. This stands for a flexible and comprehensive set of software libraries, tools, and conventions designed to simplify and standardize the task of building communication for complex and robust robot applications. Figure 1 shows the three major layers that represent ROS 2’s full architecture [2].

Figure 1 
ROS 2’s architecture overview. (Source: Automatic Addison [2])
Figure 1
ROS 2’s architecture overview. (Source: Automatic Addison [2])

At its core, ROS 2 provides a structured way for different pieces of ROS 2 units to find and exchange messages to each other, aiming for and coordinating their actions. These units, called “ROS 2 Nodes,” may be running on various processors, operating systems, or even different physical devices using the same network. Therefore, ROS 2 is, in itself, a distributed system for robotics purposes, in which robots can interact among themselves using a network for data synchronization.

From a software perspective, ROS 2 is an open-source, middleware framework Built specifically for robotic platforms, it encapsulates the crucial, yet often repetitive, low-level details of communication in robotics solutions.

It’s important to emphasize that ROS 2 is primarily designed to be used along Ubuntu Linux distro (having each ROS 2 flavor specify which Ubuntu distro must be used). Nothing stops you from using ROS 2 in some other operating system—even Windows is an OS candidate—but be aware that ROS 2 may fail in this situation. If there’s no other way, and you can’t use Ubuntu as the Linux distro of your solution, there’s an elegant workaround to save the day: use ROS 2 and its required Ubuntu distro within a Docker container.

In this article it is assumed that you are using ROS 2 along with an Ubuntu distro, using the full official documentation of the most Recent ROS 2 flavor, Foxy.

ROS 2 PURPOSE AND CORE FUNCTIONALITY

The primary purpose of ROS 2 is to offer a standardized, highly portable, and production-ready solution for the challenges of robot development. It is engineered to facilitate code reuse, modularity, and rapid prototyping, allowing developers to focus on high-level robotics algorithms (for example, perception, planning, control, and so on), rather than reinventing the wheel on communication protocols. Also, considering its distributed system’s nature, ROS 2 can be used to communicate robotics subsystems within a single robot or multiple robots. In the latter case, ROS 2 is a powerful resource to allow data synchronization among multiple robots, as a drone swarm application may require, for example.

The ROS 2’s Nodes can be developed using C++ and Python, which means that two of the most popular programming languages today have ROS 2 support (libraries and tools), contributing to its rapid adoption into real-world robotics solutions.

The key functionalities provided by ROS 2 are discussed here.

Inter-Process Communication (IPC): IPC comprises high-throughput, low-latency mechanisms for different components of the robot or robots to communicate. This includes support for four fundamental communication primitives—Topics (many-to-many), Services (request/response), Actions (long-running, goal-based tasks), and Parameters (dynamic, external configuration).

Hardware Abstraction: Standardized interfaces for sensors and actuators allow software components to operate independently of specific hardware vendors.

Package Management and Build System: ROS 2 uses a standardized build tool called “colcon” and package structure to manage complex dependencies and compilation processes across diverse systems, including cross-compilation for embedded targets. It significantly reduces the complexity of handling multiple-dependencies projects. Also, this makes it easier to port ROS 2 Nodes from one system to another, regardless of CPU architecture and operating system.

Tools and Visualization: ROS 2 offers powerful command-line utilities (ROS 2 and rqt, for example) and also graphical tools (RViz) for introspection, debugging, telemetry, and 3D visualization of the robot’s state and data flow, all of which are vital for diagnostics and development.

Also, ROS 2 allows recording the full data generated by a robot during a given time period (including sensor readings, actuator states, and camera images) into a special file called a “ROS 2 Bag.” Once a ROS 2 Bag is generated, it can be reproduced and inspected, allowing complex debug sessions without having to use the real/physical robot.

THE PUBLISH/SUBSCRIBE PARADIGM

The foundational and most frequently used communication pattern in ROS 2 is Publish/Subscribe (Pub/Sub), which is especially useful for decoupled, asynchronous message passing. In ROS 2, this pattern is implemented using Nodes, Messages, and Topics.

A Node is the basic unit in ROS 2. Each ROS 2-powered device has one or more ROS 2s running in it. A Node is an executable program responsible for handling a specific and isolated task, such as reading a sensor, reading camera frames, or commanding a motor. Also, a ROS 2 Node can communicate with other ROS 2 Nodes that are using the same network (such as a Wi-Fi network or Ethernet) over UDP using Topics. (Each message has a payload and a Topic, and all ROS 2 Nodes within the same network filter messages by its interested Topics.)

Since each ROS 2 Node is designed to be highly modular and independent, it’s expected that every robot feature is implemented within an ROS 2 Node, which means a robot, from an ROS 2 perspective, can be summarized into a set of ROS 2 Nodes.

The next part of the Pub/Sub paradigm in ROS 2 is a Message. Messages represent the payload that a ROS 2 Node wants to send to another ROS 2 Node within the same network. In ROS 2, the Messages are “typed,” meaning each message type has its own fields and rules for parsing. The message type’s scope is vast, varying from simple Strings to very complex data, like 3D-cloud points to represent light dectection and ranging (LiDAR) ambient readings. This contributes to a more standardized communication and data-parsing process, since the message format for a given type has always the expected structure and size. Figure 2 is a representation of this Pub/Sub communication in ROS 2 using Data Distribution Service (DDS).

Figure 2 
Representation of Pub/Sub communication in ROS 2 using Data Distribution Service (DDS) [2].
Figure 2
Representation of Pub/Sub communication in ROS 2 using Data Distribution Service (DDS) [2].

The last part of the Pub/Sub paradigm in ROS 2 is the Topic. Topics are named channels over which nodes exchange messages. In practical terms, they work like filters. Under the Pub/Sub model, a Message exchanging process works as described below:

First, a ROS 2 Node that generates a specific type of data (for example, robot speed) acts as a Publisher and sends messages to a designated Topic (for example, /robot/linear_speed).

Second, one or more ROS 2 Nodes that require that data (such as a ROS 2 Node that controls the robot motor and a ROS 2 that controls the robot emergency breaks) act as Subscribers and register a callback function to listen for and process messages on the same Topic.

The greatest advantage of Pub/Sub paradigm in the ROS 2 context is the decoupling of the Publisher and the Subscriber in both time and space. The ROS 2 Node that acts as a Publisher does not need to know if any ROS 2 Nodes that act as Subscribers exist in the same network, or who they are. It simply sends the data to a given Topic. Similarly, the ROS 2 Nodes that act as Subscribers to this given Topic only need to know the Topic name and Message type, remaining agnostic to the source.

This decoupling significantly increases the overall solution modularity, allowing developers to add, remove, or replace ROS 2 Nodes dynamically, without affecting the rest of the application. This is a cornerstone of scalable and maintainable robotics software. It means that ROS 2 Nodes work independently. If a ROS 2 Node faces some issue and goes offline, the other ROS 2 Nodes will continue to work.

In addition, ROS 2 does not require a central Node/concentrator to handle all the data exchanged by Topics (as happens in MQTT protocol, when referring to MQTT Broker), which means more robustness and less points-of-fail to the communication.

A single Topic can have multiple Publishers and multiple Subscribers (known as “many-to-many communication”), and ROS 2 Nodes can publish and subscribe to different Topics any time. This adds extra flexibility and scalability to the ROS 2 communication core.

ROS 2 DECENTRALIZED COMMUNICATION APPROACH

One of the most significant architectural improvements of ROS 2 over its predecessor, ROS 1, and a key factor in its reliability, is the adoption of a decentralized communication approach.

ROS 1 relied on a central entity known as the “ROS Master.” This Master Node was a central point for name registration and lookup, meaning every Node had to register with the Master, and the Master facilitated the initial connection between Publishers and Subscribers.

Despite its simplicity, this represents a major drawback—a Single Point of Failure (SPOF). If the Master failed for any reason, all Nodes would lose the ability to establish new connections or discover new components, severely compromising the robustness of the entire robotic system and often leading them to collapse. Therefore, the whole ROS 1 solution stability depends on the ROS 1 Master. If it goes offline in the network or faces any other kind of issue, the robot solution gets in trouble.

ROS 2 manages to solve this problem in a very clever way. Its communication has been highly improved, by eliminating the need for a central Master Node. It leverages the DDS, an open international standard for data-centric, real-time Publish/Subscribe communication, as shown in Figure 2. DDS handles ROS 2 Node discovery, connection establishment, and data transport in a decentralized manner.

When a ROS 2 Node starts, it uses the DDS discovery mechanism to detect other ROS 2 Nodes in the network automatically and dynamically. This discovery typically relies on multicast communication over UDP. This approach adds substantial scalability to ROS 2 solutions, since a new ROS 2 Node can be easily and seamless added to the network and communicate with other ROS 2 Nodes in the same network, all out of the box.

Figure 3 shows how ROS 2 Nodes communicate among themselves without needing a central (or Master) Node [3].

Figure 3
ROS 2 Nodes communicating among themselves without needing a Central (or Master) Node [3].
Figure 3
ROS 2 Nodes communicating among themselves without needing a Central (or Master) Node [3].

Maybe at this point you have some security concerns regarding ROS 2 Nodes, and might be asking yourself, “What if I need to create isolated (or segmented) groups of ROS 2 Nodes in the same network, and these groups must not interact with each other?” ROS 2 developers considered this scenario and implemented the ROS Domain resource.

In ROS 2, the ROS Domain (controlled by the environment variable ROS_DOMAIN_ID), is a logical namespace used to isolate communication among different sets of Nodes on the same physical network. Since ROS 2 Nodes discover each other automatically via DDS multicast, Nodes with the same domain ID will detect and communicate with each other, whereas Nodes with different domain IDs will remain isolated and not visible to each other, even if they share the same network. This mechanism allows multiple independent ROS 2 systems to run in parallel without message interference.

ROS 2 IN REAL-WORLD APPLICATIONS

The technical maturity of ROS 2, especially due to its decentralized and distributed approach, has propelled it into the forefront of real-world, production-level robotics. Some of the use-cases in which ROS 2 would be a perfect fit are discussed below:

Autonomous Vehicles: From electronics and computational perspectives, an autonomous vehicle doesn’t differ very much from a robot, since it’s able to guide itself using multiple subsystems, sensors, and actuators. In fact, today’s vehicles (including non-autonomous ones) already are distributed systems.

There’s an Electronic Control Unit (ECU) for each car subsystem, and it’s common for cars to have hundreds of ECUs. Therefore, the adoption of ROS 2 in autonomous vehicles wouldn’t be a shot in the dark.

— ADVERTISMENT—

—Advertise Here—

In this field, ROS 2 should use automotive Ethernet as Interconnection Network, and would be useful for communicating a high number of subsystems, including LiDARs, cameras, radar, inertial measurement units (IMUs), and even the current ECUs. Also, considering that Edge AI is getting more and more common for several markets, ROS 2 is particularly useful in a scenario in the automotive industry, in which ECUs dedicated to make inferences in the car can use ROS 2 to retrieve data and send commands to other ECUs, having low latency as a premise.

Drone Swarm Robotics (Multi-Agent Systems): Drones have evolved greatly in recent years, especially for tasks such as urban and rural surveillance, getting photo shoots of cities and large places, and for product deliveries (as already seen in China) where drones can deliver products such as electronics devices and food in big cities only minutes after customers buy them.

As drones become more and more common in our night and day skies, their flights need to be somehow coordinated, to avoid collisions in the air and/or damaged drones falling down on humans and buildings. In this scenario, ROS 2 would be a great fit, since there’s no SPOF in here.

Each drone could implement a set of ROS 2 Nodes and all of these drones interconnect through a WAN (5G, for example). Then, drones could retrieve other drones’ locations and avoid imminent collisions, and also ask for repair when damaged and forced-landed.

Domestic and Service Robotics: In the rapidly expanding market of domestic and service robots (for example, robotic vacuum cleaners), ROS 2 provides the necessary sophisticated and modular software infrastructure for complex, consumer-friendly devices operating in unstructured environments. A robotic vacuum cleaner must integrate sensor data, such as LiDAR for mapping and Simultaneous Localization and Mapping (SLAM), decision-making logic (such as path planning), and actuation (motor control) to work as expected.

Each of these functions can be encapsulated in a distinct ROS 2 Node, often running on an embedded Linux system. This modularity allows manufacturers to easily upgrade specific components—for instance, replacing one LiDAR with a more advanced model—by simply swapping one ROS 2 Node package, as long as it adheres to the standard Message interface.

SETTING ROS 2 ENVIRONMENT: ROS 2 FOXY ON UBUNTU

ROS 2, as happens with Linux distros, has different versions, called flavors or even distributions. Each year, a new ROS 2 flavor is released. For this article, ROS 2 Foxy flavor is used. As mentioned earlier, the recommended and most common installation path is using a Ubuntu Linux distro. For the example presented here, the ROS 2 Foxy requires Ubuntu 20.04 LTS (Focal Fossa).

Before proceeding to the ROS 2 installation, you must be running a clean, updated, installation of Ubuntu 20.04 LTS. A terminal with sudo access and Internet access also is required for the entire ROS 2 environment-setting process. The steps in this process are summarized.

Step 1—Set Locale: First of all, LANG and LC_ALL must be set to en_US.UTF-8. To ensure this, use the commands in Listing 1.

sudo apt update && sudo apt install localessudo locale-gen en_US en_US.UTF-8sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8export LANG=en_US.UTF-8

Listing 1
Setting LANG and LC_ALL to en_US.UTF-8.

After running these commands, execute the locale command to confirm LANG and LC_ALL are set to en_US.UTF-8.

Step 2—Set Up Sources for ROS 2 Repository: The ROS 2 package repository must be added to your system’s package sources list, to allow the apt package manager to find and install the Foxy distribution packages. To do so, use the commands shown in Listing 2.

sudo apt install software-properties-common
sudo add-apt-repository universe

sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo “deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ROS 2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main” | sudo tee /etc/apt/sources.list.d/ROS 2.list > /dev/null

Listing 2
Set up sources for ROS 2 repository.

Step 3—Install ROS 2 Packages (Foxy): With the repository correctly configured, you must first update the local package cache and then proceed with the installation. It is also recommended to upgrade all existing packages to ensure compatibility with ROS 2 dependencies. To do so, use the following commands:

sudo apt update && sudo apt upgrade

sudo apt install ros-foxy-desktop python3-argcomplete ros-foxy-ros-base python3-argcomplete ros-dev-tools

Step 4—Environment Setup: The ROS 2 installation process places its executables and configuration files in the system’s /opt/ros/foxy directory. To make the ROS 2 commands and libraries available to your shell, the environment must be correctly configured. This is achieved by using the following command:

source /opt/ros/foxy/setup.bash

Important: Before executing any ROS 2 command in a new terminal session, the command shown here must be executed. Adding it to your ~/.bashrc file is a good call to execute this command automatically every time a new terminal session is launched. From this point on, ROS 2 is fully installed in your computer.

ROS 2 AND RASPBERRY PI: GETTING STARTED

Now it’s time to put two ROS 2 Nodes in communication, one running in your computer and other running in a Raspberry Pi. The prerequisites for this practical example are listed.

  • Hardware Prerequisite: Preferably, use the most recent versions of Raspberry Pi (4 or 5).
  • Raspberry Pi Operating System: Install Ubuntu 20.04 LTS (Focal Fossa) as the Raspberry Pi operating system.
  • Network Prerequisites: Ensure that both the Raspberry Pi and your computer are on the same local network. It doesn’t matter if you use Ethernet or Wi-Fi, as long as they are in the same network.

Once the prerequisites are fulfilled, it’s time to install ROS 2 in your Raspberry Pi. To do so, follow the same steps given in the preceding section, “Setting ROS 2 Environment: ROS 2 Foxy on Ubuntu,” in your Raspberry Pi.

— ADVERTISMENT—

—Advertise Here—

In this practical example, the Raspberry Pi will work as a Publisher (implemented in Python), and your computer as a Listener (implemented in C++). To quickly test this scenario, there’s an out-of-the-box example in ROS 2 called demo_nodes_cpp (for Publisher) and demo_nodes_py (for Listener).

Enabling Publisher in Raspberry Pi: To enable and run the ROS 2 Node that works as a Publisher on Raspberry Pi, run the following command. It runs the demo_nodes_cpp example as a “Talker” (an alternative name for Publisher in ROS 2 documentation).

ROS 2 run demo_nodes_cpp talker

Enabling Subscriber in Raspberry Pi: To enable and run the ROS 2 Node that works as a Subscriber on your computer, run the following command on it. It runs the demo_nodes_cpp example as a “Listener” (an alternative name for Subscriber in ROS 2 documentation).

ROS 2 run demo_nodes_py listener

Then, you should see the Publisher (Raspberry Pi) publishing the Messages, and the Listener (your computer) receiving these Messages, which validates ROS 2 communication between two ROS 2 Nodes located in different machines in a local network.

From Research to Production

The evolution from ROS 1 to the current Robot Operating System, ROS 2, marks a decisive shift in robotics middleware, moving from a research-oriented tool to a robust, production-grade framework suitable for mission-critical, distributed systems.

This comprehensive review has detailed how ROS 2’s architectural foundations, particularly its adoption of the decentralized Data Distribution Service as its communication layer, successfully address the core limitations of its predecessor.

The elimination of the SPOF inherent in the centralized Master Node architecture directly translates to superior fault tolerance and reliability, which are non-negotiable requirements for industrial automation, autonomous vehicles, and safety-critical multi-agent systems.

By treating the local network as a self-discovering Interconnection Network, ROS 2 enables computational nodes—whether they are high-power PCs or constrained embedded platforms such as the Raspberry Pi—to form a cohesive, distributed application space.

The practical demonstration of communication between a host PC and a Raspberry Pi, exchanging standardized data via the simple yet powerful Publish/Subscribe paradigm, underscores ROS 2’s effectiveness in seamlessly integrating heterogeneous hardware components into a single, functional, robotic system.

ROS 2 is not merely an incremental update. Rather, it is the state-of-the-art solution that offers the modularity, scalability, and security demanded by the next generation of complex, networked robotics applications—from large-scale drone swarms to intricate domestic machines. Its open-source nature ensures continued development and adoption, cementing its role as the industry standard for collaborative and autonomous system development worldwide.

RESOURCES
Raspberry Pi | https://www.raspberrypi.com
Ubunto Linus | https://ubuntu.com

REFERENCES
[1] Source: https://automaticaddison.com/ros-2-architecture-overview/
[2] Source: https://docs.ros.org/en/foxy/index.html
[3] Source: https://www.mathworks.com/help/ros/gs/robot-operating-system-ROS 2-basic-concepts.html

— ADVERTISMENT—

—Advertise Here—

Code and Supporting Files

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • FEBRUARY 2026 #427 – Get a PDF of the issue

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2026 KCK Media Corp.

Robot Operating System 2 (ROS 2)

by Pedro Bertoleti time to read: 15 min