Robot Operating System 2, commonly known as ROS 2, has become the dominant framework for building robotics applications worldwide. From research labs to commercial deployments, ROS 2 provides the foundation that enables developers to create sophisticated robot systems without reinventing core functionality.
This guide walks through everything you need to know to start developing with ROS 2. Whether you are new to robotics programming or transitioning from ROS 1, understanding the fundamentals covered here will establish a solid foundation for more advanced development.
By the end of this guide, you will understand ROS 2 architecture, have a working installation, and possess the knowledge to start building your own robotic applications. The concepts apply across robot types, from simple mobile platforms to complex industrial arms.
Table of Contents
- What Is ROS 2 and Why Does It Matter?
- ROS 1 vs ROS 2: Key Differences
- Understanding ROS 2 Architecture
- Installing ROS 2 on Your System
- Core Concepts: Nodes, Topics, and Services
- Building Your First ROS 2 Project
- Essential ROS 2 Tools and Commands
- Next Steps and Advanced Topics
- Frequently Asked Questions
What Is ROS 2 and Why Does It Matter?
ROS 2 is an open-source framework for building robot software. Despite the name “Operating System,” ROS 2 runs on top of conventional operating systems like Ubuntu Linux, Windows, and macOS. It provides libraries, tools, and conventions that simplify creating complex robot behaviors.
The Problem ROS Solves
Building robots requires solving many common problems: communicating between software components, interfacing with hardware, coordinating multiple processes, and visualizing data. Before ROS, every robotics project implemented these capabilities from scratch.
ROS provides standardized solutions to these problems:
- Communication infrastructure: Publish-subscribe messaging between components
- Hardware abstraction: Standard interfaces for sensors and actuators
- Package management: Easy sharing and reuse of code
- Tool ecosystem: Visualization, simulation, and debugging tools
- Community packages: Thousands of pre-built capabilities
Who Uses ROS 2?
ROS 2 adoption spans multiple industries:
- Research institutions: Universities and labs developing new robotics capabilities
- Commercial robotics: Companies building production robot systems
- Automotive: Self-driving car developers and ADAS systems
- Aerospace: Drone manufacturers and space robotics
- Industrial automation: Manufacturing and logistics robots
Why ROS 2 Over ROS 1?
ROS 2 represents a complete redesign addressing limitations of the original ROS. Key improvements include real-time capability, production-grade quality, multi-robot support, and security features that ROS 1 lacked.
ROS 1 vs ROS 2: Key Differences
Understanding the differences between ROS 1 and ROS 2 helps contextualize design decisions and explains why the robotics community is transitioning to the newer version.
Communication Layer
ROS 1 used a custom communication system with a central Master node. ROS 2 replaces this with Data Distribution Service (DDS), an industry-standard middleware:
- No single point of failure: ROS 2 has no central master that can crash
- Better networking: Works across subnets and firewalls
- Quality of Service: Configure reliability, durability, and deadline requirements
- Security: Built-in encryption and authentication
Real-Time Support
ROS 1 was not designed for real-time applications. ROS 2 supports real-time systems:
- Deterministic execution: Predictable timing for critical applications
- Memory management: Pre-allocation to avoid runtime allocation
- Executor options: Different execution models for different needs
Multi-Platform Support
While ROS 1 primarily ran on Ubuntu, ROS 2 officially supports:
- Ubuntu Linux (20.04, 22.04, 24.04)
- Windows 10 and 11
- macOS
- Various embedded platforms
Build System
ROS 2 uses colcon as its build tool, replacing catkin from ROS 1. The new system offers improved dependency handling, parallel builds, and better integration with standard CMake workflows.
Lifecycle Management
ROS 2 introduces managed lifecycle nodes that provide standardized states (unconfigured, inactive, active, finalized). This enables better system control and coordinated startup and shutdown procedures.
Understanding ROS 2 Architecture
ROS 2 architecture consists of multiple layers, each providing specific functionality. Understanding these layers helps developers make appropriate design decisions.
Application Layer
Your robot software lives at the application layer. This includes custom nodes you write, packages you create, and robot-specific logic. The application layer uses client libraries to interact with ROS 2 infrastructure.
Client Libraries (rclpy, rclcpp)
ROS 2 provides client libraries for different programming languages:
- rclcpp: C++ client library for performance-critical applications
- rclpy: Python client library for rapid development and scripting
- rclnodejs: Node.js library for web integration
- rcljava: Java library for Android and enterprise applications
ROS Client Library (rcl)
The rcl layer provides a common C API that all client libraries build upon. This ensures consistent behavior regardless of which programming language you use.
ROS Middleware Interface (rmw)
The rmw layer abstracts the underlying DDS implementation. This allows switching between different DDS vendors without changing application code:
- Fast DDS: Default implementation, good general performance
- Cyclone DDS: Excellent for embedded and resource-constrained systems
- Connext DDS: Commercial option with enterprise support
DDS Layer
Data Distribution Service provides the actual communication. DDS is an established standard used in aerospace, defense, and industrial systems for reliable real-time communication.
Installing ROS 2 on Your System
This section covers installation on Ubuntu Linux, the most common platform for ROS 2 development. The current Long Term Support release is ROS 2 Jazzy Jalisco for Ubuntu 24.04.
System Requirements
Before installing, verify your system meets these requirements:
- Operating system: Ubuntu 24.04 LTS (Jazzy) or Ubuntu 22.04 LTS (Humble/Iron)
- Architecture: AMD64 or ARM64
- RAM: Minimum 4 GB, 8 GB or more recommended
- Storage: At least 10 GB free space
Installation Steps
Follow these steps to install ROS 2 Jazzy on Ubuntu 24.04:
1. Set up the repository:
Enable the Ubuntu Universe repository and add the ROS 2 GPG key and repository to your system.
2. Install ROS 2 packages:
Install the desktop package for a full development environment, or ros-base for a minimal installation without GUI tools.
3. Configure your environment:
Add the ROS 2 setup script to your shell configuration file so ROS 2 commands are available in every terminal session.
Verifying Installation
Test your installation by running the demo talker and listener nodes. Open two terminals and run the talker in one and listener in the other. You should see messages being published and received.
Installing Additional Tools
For development, you should also install:
- colcon: The build tool for ROS 2 workspaces
- rosdep: Dependency management for ROS packages
- RViz2: Visualization tool (included in desktop install)
- Gazebo: Robot simulation environment
Core Concepts: Nodes, Topics, and Services
ROS 2 organizes software into several key abstractions. Understanding these concepts is essential for building any ROS 2 application.
Nodes
A node is a single executable that performs computation. Robots typically consist of many nodes working together:
- One node might control wheel motors
- Another node processes camera images
- A third node performs path planning
- A fourth node handles user commands
Nodes should be modular, handling one specific function. This design allows reusing nodes across different robots and simplifies debugging.
Topics
Topics provide anonymous publish-subscribe communication. Nodes publish messages to topics without knowing who subscribes, and nodes subscribe without knowing who publishes:
- Publishers: Send messages to a named topic
- Subscribers: Receive messages from a named topic
- Messages: Typed data structures (sensor readings, commands, etc.)
This decoupling allows flexible system composition. Multiple publishers can write to the same topic, and multiple subscribers can read from it.
Services
Services provide request-response communication when you need a reply:
- Server: Provides a named service, responds to requests
- Client: Sends requests to a service, waits for responses
Use services for operations that need confirmation, like setting parameters or triggering specific actions.
Actions
Actions handle long-running tasks that need feedback and can be canceled:
- Goal: The request specifying what to achieve
- Feedback: Progress updates during execution
- Result: The final outcome when complete
Navigation goals commonly use actions since they take time and benefit from progress updates.
Parameters
Parameters store configuration values that nodes can get and set at runtime. Unlike topics, parameters are specific to individual nodes and persist across service calls.

Building Your First ROS 2 Project
This section walks through creating a simple ROS 2 package with a publisher and subscriber node. This foundational example demonstrates the core workflow.
Creating a Workspace
ROS 2 projects live in workspaces. Create a workspace directory with a src folder inside. The src folder holds your packages, while the workspace root contains build artifacts.
Creating a Package
Use the ros2 pkg create command to generate a new package. Specify the build type (ament_python for Python, ament_cmake for C++) and any dependencies your package needs.
For a Python package, specify rclpy as a dependency. The command creates the package structure including setup files and a source directory.
Writing a Publisher Node
A minimal publisher node requires:
- Import the rclpy library and message types
- Initialize the ROS 2 runtime
- Create a node with a name
- Create a publisher specifying topic name, message type, and queue size
- Create a timer to periodically publish messages
- Spin the node to process callbacks
Writing a Subscriber Node
A minimal subscriber node needs:
- Initialize ROS 2 and create a node
- Create a subscription with topic name, message type, callback function, and queue size
- Define the callback function to process received messages
- Spin to process incoming messages
Building and Running
Build your workspace using colcon build from the workspace root. After building, source the install script to make your packages available, then use ros2 run to execute nodes.
Observing Communication
Use ros2 topic list to see available topics and ros2 topic echo to view messages on a topic. These tools help verify your nodes communicate correctly.
Essential ROS 2 Tools and Commands
ROS 2 includes command-line tools for inspecting, debugging, and interacting with running systems. Mastering these tools significantly improves development efficiency.
Node Management
Commands for working with nodes:
- ros2 node list: Show all running nodes
- ros2 node info: Display node details including publishers, subscribers, services
- ros2 run: Execute a node from a package
Topic Tools
Commands for working with topics:
- ros2 topic list: List all active topics
- ros2 topic echo: Print messages on a topic
- ros2 topic pub: Publish messages from command line
- ros2 topic hz: Show publishing rate
- ros2 topic info: Show topic type and connected nodes
Service Tools
Commands for working with services:
- ros2 service list: List available services
- ros2 service call: Call a service from command line
- ros2 service type: Show service type
Parameter Tools
Commands for working with parameters:
- ros2 param list: List parameters for a node
- ros2 param get: Get parameter value
- ros2 param set: Set parameter value
Visualization Tools
Graphical tools for understanding system structure:
- RViz2: 3D visualization of sensor data, robot state, and maps
- rqt_graph: Visualize node and topic connections
- rqt_console: View and filter log messages
- rqt_plot: Plot numeric data from topics
Recording and Playback
ros2 bag records topic data to files that can be replayed later. This capability is invaluable for debugging and testing:
- ros2 bag record: Record topics to a bag file
- ros2 bag play: Replay recorded data
- ros2 bag info: Show bag file contents

Next Steps and Advanced Topics
After mastering the basics, several advanced topics will expand your ROS 2 capabilities.
Launch Files
Launch files start multiple nodes with configured parameters. Learn to write Python launch files that specify node configurations, remappings, and composition.
Simulation with Gazebo
Gazebo provides physics-based robot simulation integrated with ROS 2. Simulating before deploying to hardware saves time and prevents damage.
Navigation Stack
Nav2 provides autonomous navigation capabilities including path planning, obstacle avoidance, and behavior trees for complex mission execution.
Manipulation with MoveIt
MoveIt provides motion planning for robot arms. It handles collision avoidance, inverse kinematics, and trajectory execution.
Creating Custom Message Types
Define custom messages when standard types do not meet your needs. Message definitions specify fields and types that compile into language-specific code.
Hardware Integration
ros2_control provides standard interfaces for robot hardware. Understanding controllers and hardware interfaces enables clean hardware abstraction.
How to Practice ROS 2 Development
Build your skills progressively:
- Start with tutorials: Complete the official ROS 2 tutorials
- Use simulation: Experiment with TurtleBot3 in Gazebo
- Build projects: Create small projects that combine concepts
- Study existing packages: Read code from popular ROS 2 packages
- Join the community: Ask questions on ROS Answers and Discord


