🤖 Introduction to ROS Architecture
ROS (Robot Operating System) is not a traditional OS, but a flexible middleware
framework that helps developers build robot applications by providing tools, libraries, and
communication infrastructure.
🧩 Core Concepts of ROS Architecture
ROS follows a distributed, modular architecture, where different parts of a robot system
run as independent processes and communicate with each other.
1. 🟢 Nodes
A node is a small program that performs a specific task.
Example:
o Sensor node → reads data from sensors
o Control node → processes data and sends commands
👉 Think of nodes as building blocks of a robot system.
2. 🔵 Topics (Publish/Subscribe Model)
Nodes communicate using topics.
One node publishes data, another subscribes to it.
📌 Example:
Camera node publishes images → Vision node subscribes to images
✔️Key idea:
Asynchronous communication
Decoupled (nodes don’t need to know each other)
3. 🟡 Messages
Data is exchanged in the form of messages.
Predefined structures (e.g., sensor data, velocity commands)
📌 Example:
sensor_msgs/Image
geometry_msgs/Twist
4. 🔴 Services (Request/Response)
Used for synchronous communication.
One node sends a request, another sends a response.
📌 Example:
Ask a robot: “What is your current position?”
✔️Best for:
Immediate actions
Queries
5. 🟣 Actions
Similar to services but used for long-running tasks.
Provide:
o Feedback
o Result
o Ability to cancel
📌 Example:
Move robot to a location (takes time, needs updates)
6. ⚙️ROS Master
Central coordinator (in ROS 1).
Helps nodes:
o Find each other
o Establish communication
📌 Important:
Once connected, nodes communicate peer-to-peer.
7. 📦 Packages
A package is a collection of:
o Nodes
o Libraries
o Configuration files
👉 It’s the basic unit for organizing ROS code.
8. 🛠️ROS Tools
Some essential tools include:
roscore → starts ROS system
rosrun → runs nodes
roslaunch → launches multiple nodes
rviz → visualization tool
rqt → GUI tools for debugging
🏗️ROS Architecture Overview (Simplified Flow)
Sensors → [Sensor Node] → (Topic) → [Processing Node] → (Topic) → [Control
Node] → Actuators
🔄 ROS 1 vs ROS 2 (Quick Note)
Feature ROS 1 ROS 2
Communication ROS Master DDS (no master)
Real-time Limited Better support
Security Weak Improved
Multi-robot Difficult Easier
🧠 Key Advantages of ROS Architecture
Modular and scalable
Reusable components
Strong community support
Hardware abstraction
🤖 ROS 2 Architecture (Robot Operating
System 2)
ROS 2 is the next-generation robotics middleware designed to overcome the limitations of
ROS 1—especially in real-time systems, scalability, and distributed robotics.
🧩 Key Idea of ROS 2 Architecture
Unlike ROS 1, ROS 2 uses DDS (Data Distribution Service) as its communication
backbone, enabling decentralized, peer-to-peer communication without a master node.
🧱 Core Components of ROS 2 Architecture
1. 🟢 Nodes
Same concept as ROS 1
A node is an independent process performing a task
📌 Example:
Sensor node
Localization node
Navigation node
2. 🔵 Topics (Publish/Subscribe)
Nodes exchange data using topics
Based on DDS for efficient communication
✔️Features:
Asynchronous
Many-to-many communication
Supports QoS (Quality of Service)
3. 🟡 Messages
Structured data used in topics
📌 Examples:
std_msgs/String
sensor_msgs/LaserScan
4. 🔴 Services (Synchronous Communication)
Request/Response model
📌 Example:
Reset a robot system
Get sensor status
5. 🟣 Actions (Long-running Tasks)
Used for operations that:
o Take time
o Require feedback
📌 Example:
Autonomous navigation to a goal
✔️Provides:
Goal
Feedback
Result
Cancel option
6. ⚙️DDS (Data Distribution Service)
This is the core of ROS 2 architecture.
✔️Responsibilities:
Discovery of nodes
Message delivery
QoS management
✔️Benefits:
No central master
Real-time capable
Reliable communication
7. 🎚️Quality of Service (QoS)
A major improvement in ROS 2.
✔️Controls:
Reliability (reliable vs best effort)
Durability
Latency
History (how much data to store)
📌 Example:
Sensor data → best effort
Control commands → reliable
8. 📦 Packages and Workspaces
Same concept as ROS 1 but improved build system
✔️Tools:
colcon(build system)
Workspaces organize multiple packages
9. 🧵 Executors and Callback Groups
Handle how nodes process data
✔️Executors:
Manage execution of callbacks
Single-threaded or multi-threaded
✔️Callback groups:
Control concurrency inside nodes
10. 🔐 Security (SROS2)
Built-in security support
✔️Features:
Encryption
Authentication
Access control
11. 🌐 Multi-Robot & Distributed Systems
Designed for:
o Cloud robotics
o Multi-robot communication
o Edge devices
🏗️ROS 2 Architecture Flow
Sensors → Node → DDS → Node → Actuators
↑
(QoS-controlled communication)
🔄 ROS 1 vs ROS 2 Architecture
Feature ROS 1 ROS 2
Communication ROS Master DDS (peer-to-peer)
Real-time Limited Strong
support
QoS Not available Available
Security Minimal Built-in
Scalability Moderate High
🧠 Key Advantages of ROS 2 Architecture
No single point of failure (no master)
Real-time communication support
Fine control using QoS
Secure communication
Suitable for industrial applications
Setting Up a ROS 2 Development
Environment
ROS 2 is recommended over ROS 1 for modern robotics.
💻 1. System Requirements
OS: Ubuntu 22.04 (recommended)
ROS 2 Distribution: Humble Hawksbill (LTS)
📦 2. Install ROS 2 (Humble)
Step 1: Setup Locale
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
Step 2: Add ROS 2 Repository
sudo apt install software-properties-common
sudo add-apt-repository universe
Step 3: Add ROS 2 GPG Key
sudo apt update && sudo apt install curl -y
sudo curl -sSL
[Link] -o
/usr/share/keyrings/[Link]
Step 4: Add Source List
echo "deb [signed-by=/usr/share/keyrings/[Link]]
[Link] $(. /etc/os-release && echo
$UBUNTU_CODENAME) main" | sudo tee /etc/apt/[Link].d/[Link]
Step 5: Install ROS 2
sudo apt update
sudo apt install ros-humble-desktop
Step 6: Source ROS 2 Environment
echo "source /opt/ros/humble/[Link]" >> ~/.bashrc
source ~/.bashrc
🧪 3. Test Installation
ros2 run demo_nodes_cpp talker
Open another terminal:
ros2 run demo_nodes_py listener
✔️If messages appear → ROS 2 is working!
🧰 4. Install Development Tools
sudo apt install python3-colcon-common-extensions
sudo apt install ros-dev-tools
📁 5. Create a Workspace
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
colcon build
🔄 6. Source Workspace
source install/[Link]
🤖 ROS 2 Basics (Core Concepts)
🧩 1. Nodes
Small programs performing tasks
📌 Example:
Camera node
Motor control node
🔵 2. Topics (Publish/Subscribe)
Nodes communicate via topics
✔️Example:
Publisher → sends data
Subscriber → receives data
ros2 topic list
ros2 topic echo /topic_name
🟡 3. Messages
Data structures used in communication
📌 Example:
std_msgs/String
geometry_msgs/Twist
🔴 4. Services
Request/Response communication
ros2 service list
ros2 service call /service_name
🟣 5. Actions
Long-running tasks with feedback
✔️Example:
Navigation goals
⚙️6. Packages
Organized collection of ROS code
ros2 pkg create my_package
🧵 7. Build System (colcon)
colcon build
🧪 8. Useful CLI Commands
Nodes
ros2 node list
ros2 node info /node_name
Topics
ros2 topic list
ros2 topic info /topic_name
Services
ros2 service list
🖥️9. Visualization Tools
rviz2 → visualize robot data
rqt → debugging tools
🏗️Basic ROS 2 Workflow
Create Package → Write Node → Build (colcon) → Source → Run Node
🧠 Key Tips for Beginners
Always source your workspace
Use separate terminals for nodes
Start with Python (rclpy) for easier learning
Practice with small projects:
o Publisher/Subscriber
o Simple robot movement
🟢 1. ROS Nodes
📌 Definition
A node is an independent program that performs a specific task in a robot system.
🧠 Key Points
Each node does one job
Nodes communicate with each other
Can be written in Python (rclpy) or C++ (rclcpp)
📍 Example
Camera node → captures images
Motor node → controls wheels
Navigation node → plans movement
✔️Think of nodes as modular components of a robot.
🔵 2. ROS Topics
📌 Definition
A topic is a communication channel used by nodes to exchange data using a
publish/subscribe model.
🧠 How It Works
Publisher node → sends data
Subscriber node → receives data
📍 Example
/camera/image topic:
o Camera node publishes images
o Vision node subscribes to images
✅ Features
Asynchronous communication
Many-to-many connection
Decoupled (nodes don’t depend directly)
🟡 3. ROS Messages
📌 Definition
A message is the data format used to communicate over topics, services, and actions.
🧠 Key Points
Predefined or custom structures
Define the type of data
📍 Examples
std_msgs/String → text
geometry_msgs/Twist → velocity
sensor_msgs/Image → camera data
✔️Example Structure
string data
🔴 4. ROS Services
📌 Definition
A service is a communication method based on a request–response model.
🧠 How It Works
Client sends request
Server processes and sends response
📍 Example
Request: “Give current position”
Response: “(x, y, z) coordinates”
✅ Features
Synchronous communication
Immediate response
Used for quick operations
✔️Command Example
ros2 service list
🟣 5. ROS Actions
📌 Definition
An action is used for long-running tasks that need feedback during execution.
🧠 How It Works
Client sends a goal
Server executes task
Sends:
o Feedback (progress updates)
o Result (final output)
📍 Example
Move robot to a destination
Pick and place an object
✅ Features
Asynchronous
Can be cancelled
Provides continuous feedback
⚖️Services vs Actions (Important
Difference)
Feature Services Actions
Type Request–Response Goal–Feedback–Result
Duration Short tasks Long-running tasks
Feedback ❌ No ✅ Yes
Cancellation ❌ No ✅ Yes
🏗️Overall Communication Flow
Node → Topic (Message) → Node
Node → Service (Request/Response) → Node
Node → Action (Goal/Feedback/Result) → Node
🧠 Simple Analogy
Concept Real-Life Example
Node Worker in a factory
Topic Broadcast system
Message Information being sent
Service Phone call (ask → get answer)
Concept Real-Life Example
Action Food delivery (order → track → receive)