ROS Framework
Learn the Robot Operating System (ROS) — the industry-standard middleware for building modular, scalable robot software with nodes, topics, and services.
What is ROS?
The Robot Operating System (ROS) is an open-source middleware framework that provides tools, libraries, and conventions for writing robot software. Despite its name, ROS is not an operating system — it runs on top of Linux (primarily Ubuntu) and provides a structured communication layer between software components called nodes.
ROS 2 (the current generation) is built on the DDS (Data Distribution Service) communication standard, offering improved real-time performance, security, and multi-platform support compared to ROS 1.
Core ROS 2 Concepts
Nodes
Independent processes that perform specific tasks (e.g., camera driver, object detector, motor controller). Nodes communicate via topics and services.
Topics
Named buses for publish/subscribe messaging. A camera node publishes images on /camera/image_raw, and any node can subscribe to receive them.
Services
Request/response communication for synchronous operations. A node can request a path from the planner and wait for the result.
Actions
Long-running tasks with feedback. Navigate to a goal, receive progress updates, and get a final result — with the ability to cancel mid-execution.
Setting Up ROS 2
# Install ROS 2 Humble on Ubuntu 22.04
sudo apt update && sudo apt install -y ros-humble-desktop
# Source the ROS 2 environment
source /opt/ros/humble/setup.bash
# Create a workspace
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
colcon build
source install/setup.bash
Your First ROS 2 Node
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
class HelloRobot(Node):
def __init__(self):
super().__init__('hello_robot')
self.publisher = self.create_publisher(String, 'greetings', 10)
self.timer = self.create_timer(1.0, self.publish_message)
def publish_message(self):
msg = String()
msg.data = 'Hello from AI Robotics!'
self.publisher.publish(msg)
self.get_logger().info(f'Published: {msg.data}')
def main():
rclpy.init()
node = HelloRobot()
rclpy.spin(node)
node.destroy_node()
rclpy.shutdown()
Essential ROS 2 Packages for AI Robotics
| Package | Purpose | Use Case |
|---|---|---|
| nav2 | Navigation stack | Autonomous mobile robot navigation |
| MoveIt 2 | Motion planning | Robotic arm manipulation |
| image_pipeline | Camera processing | Image rectification, depth processing |
| ros2_control | Hardware abstraction | Motor controllers, actuator interfaces |
| tf2 | Coordinate transforms | Tracking spatial relationships between frames |
| pcl_ros | Point cloud processing | LiDAR data processing and filtering |
Lilly Tech Systems