Skip to main content

Introduction to ROS 2

Overview

Robot Operating System 2 (ROS 2) is a flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robot platforms.

Unlike traditional operating systems, ROS 2 is not an actual OS but rather a middleware that provides services designed for a heterogeneous computer cluster. It includes hardware abstraction, device drivers, libraries, visualizers, message-passing, package management, and more.

Key Concepts

Nodes

Nodes are processes that perform computation. ROS 2 is designed to be modular, with each node performing a specific task. Nodes can be written in different programming languages (C++, Python, etc.) and can run on different machines.

Topics and Messages

Topics are named buses over which nodes exchange messages. Messages are the data structures that are passed between nodes. They are defined using the .msg file format and can contain primitive data types and other message types.

Services

Services provide a request/response communication pattern. A node can offer a service, and other nodes can call that service to request specific actions or information.

Actions

Actions are similar to services but are designed for long-running tasks. They provide feedback during execution and can be canceled if needed.

ROS 2 vs ROS 1

ROS 2 was developed to address limitations in ROS 1 and to meet the needs of commercial robotics applications:

  • Real-time support: ROS 2 supports real-time operations, which was not available in ROS 1
  • Multi-robot systems: Better support for multiple robots working together
  • Platform support: ROS 2 runs on various platforms including Windows, macOS, and Linux
  • Security: Built-in security features for commercial applications
  • Middleware: Uses DDS (Data Distribution Service) as the underlying communication layer

Installation and Setup

ROS 2 is available for multiple platforms. The most common installation is on Ubuntu Linux, but it's also available for Windows and macOS. The latest distributions include features for different use cases and maturity levels.

For this textbook, we'll be using the latest LTS (Long Term Support) version of ROS 2, which provides stability and long-term maintenance for production applications.

Practical Applications in Humanoid Robotics

In humanoid robotics, ROS 2 serves as the backbone for communication between different subsystems:

  • Sensor integration: Collecting data from cameras, IMUs, force sensors, etc.
  • Control systems: Managing joint control, balance, and locomotion
  • Perception: Processing visual and sensory data
  • Planning: Path planning, motion planning, and task planning
  • Human-robot interaction: Voice, gesture, and interface management

Summary

ROS 2 provides a robust foundation for developing complex robotic applications. Its modular architecture, multi-language support, and rich ecosystem of packages make it an ideal choice for humanoid robotics development. In the following chapters, we'll explore the architecture, communication patterns, and practical implementation of ROS 2 in humanoid robotics applications.