Weeks 3-5: ROS 2 Fundamentals
Learning Objectives
During these three weeks, students will master the core concepts and tools of ROS 2, the middleware framework that enables communication between different components of a robotic system.
Topics Covered
-
ROS 2 architecture and core concepts
- Understanding the distributed computing model
- Nodes, topics, services, and actions
- The DDS (Data Distribution Service) communication layer
-
Nodes, topics, services, and actions
- Creating and managing ROS 2 nodes
- Publisher-subscriber pattern with topics
- Request-response pattern with services
- Long-running tasks with actions
-
Building ROS 2 packages with Python
- Package structure and organization
- Creating nodes in Python using rclpy
- Managing dependencies and build configurations
-
Launch files and parameter management
- Organizing complex systems with launch files
- Managing system parameters
- Configuration management for different environments
Key Concepts
ROS 2 Architecture
ROS 2 uses a distributed computing architecture based on the Data Distribution Service (DDS) standard. This provides:
- Decentralized communication: No single point of failure
- Language independence: Nodes can be written in different programming languages
- Transport flexibility: Multiple transport mechanisms (TCP, UDP, shared memory)
- Quality of Service (QoS): Configurable communication behavior for different use cases
Communication Patterns
ROS 2 provides four main communication patterns:
- Topics (Publish/Subscribe): Asynchronous, many-to-many communication
- Services (Request/Response): Synchronous, one-to-one communication
- Actions: Asynchronous, long-running tasks with feedback
- Parameters: Configuration values shared across nodes
rclpy
rclpy is the Python client library for ROS 2. It provides:
- Node creation and management
- Publisher and subscriber interfaces
- Service and action clients/servers
- Parameter handling
- Time and logging utilities
Practical Exercises
- Create a simple publisher and subscriber
- Implement a service server and client
- Build a ROS 2 package with multiple nodes
- Use launch files to start complex systems
- Manage parameters for different robot configurations
Assignments
- ROS 2 package development project
- Implement a simple robot controller using ROS 2
- Create a launch file for a multi-node system