Learn ROS-ROS2 with Real Code Examples
Updated Nov 27, 2025
Explain
ROS uses a node-based architecture where each node performs a specific task, communicating via topics, services, and actions.
ROS2 improves on ROS1 by adding real-time capabilities, DDS-based communication, and better security and multi-robot support.
Both ROS and ROS2 abstract hardware through device drivers and hardware interfaces, allowing platform-independent programming.
Supports simulation, visualization, and testing through tools like Gazebo, RViz, and rqt.
Widely used in academic research, industrial robotics, autonomous vehicles, and robotic middleware development.
Core Features
Pub-sub messaging system for asynchronous communication
Service calls for synchronous operations
Action interfaces for long-running tasks
Parameter server and configuration management
Integration with Gazebo, RViz, and other visualization/simulation tools
Basic Concepts Overview
Nodes - independent processes performing tasks
Topics - asynchronous message communication
Services - synchronous request/response calls
Actions - preemptable long-running tasks
Parameters - runtime configuration values
Project Structure
src/ - source code of nodes
msg/ - custom message definitions
srv/ - custom service definitions
launch/ - launch files for starting multiple nodes
CMakeLists.txt & package.xml - build configuration and dependencies
Building Workflow
Create a workspace and packages
Write nodes in Python or C++
Define messages and services as needed
Build the package using `catkin_make` or `colcon build`
Run and test nodes individually and in combination
Difficulty Use Cases
Beginner: Create a talker/listener node
Intermediate: Implement simple navigation or sensor processing
Advanced: Multi-robot coordination with ROS2 DDS
Expert: Real-time perception and control on embedded platforms
Architect: Design full-stack robotics middleware with ROS2
Comparisons
ROS1 vs ROS2: ROS2 adds real-time support, DDS communication, and security
ROS vs custom C++ robotics frameworks: ROS provides standard middleware and ecosystem
ROS2 vs microcontroller firmware: ROS2 handles high-level logic; low-level drivers run on embedded firmware
ROS2 vs proprietary robot SDKs: ROS2 is open-source, modular, and flexible
ROS2 vs MATLAB Robotics Toolbox: ROS2 is runtime, open-source middleware; MATLAB is simulation and prototyping
Versioning Timeline
2007β2009 - ROS1 created at Stanford and Willow Garage
2010 - ROS1 community adoption begins
2014 - ROS2 development starts by Open Robotics
2017 - ROS2 Ardent release with improved QoS and security
2019 - ROS2 Dashing and Eloquent release with LTS support
2022 - ROS2 Humble release stabilizes multi-platform support
2025 - ROS2 widely adopted in industrial and autonomous systems
Glossary
Node - independent process performing tasks
Topic - asynchronous message channel
Service - synchronous request-response
Action - long-running preemptable task
DDS - Data Distribution Service (ROS2 communication middleware)