ros2-patterns

zeeshan080's avatarfrom zeeshan080

ROS 2 node templates and message types for robotics development. Use when creating ROS 2 nodes, understanding message types, or writing publisher/subscriber patterns.

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 3, 2025

When & Why to Use This Skill

This Claude skill streamlines ROS 2 robotics development by providing standardized node templates, message type references, and common communication patterns. It helps developers quickly scaffold publishers, subscribers, and service servers while ensuring adherence to ROS 2 Humble conventions, proper error handling, and structured documentation.

Use Cases

  • Rapid Prototyping: Quickly generate boilerplate code for new ROS 2 nodes to focus on core robotics logic rather than infrastructure setup.
  • Communication Implementation: Efficiently set up publisher and subscriber patterns for seamless data exchange between different robotic sensors and actuators.
  • Standardization and Best Practices: Ensure all robotics code follows ROS 2 Humble conventions, including proper node lifecycle management and error handling routines.
  • Learning and Reference: Use as a quick reference for ROS 2 message types and standard node structures for developers transitioning to robotics engineering.
nameros2-patterns
descriptionROS 2 node templates and message types for robotics development. Use when creating ROS 2 nodes, understanding message types, or writing publisher/subscriber patterns.
allowed-toolsRead, Bash

ROS 2 Patterns

Instructions

When creating ROS 2 code:

  1. Use the provided templates as starting points
  2. Follow ROS 2 Humble conventions
  3. Include proper error handling
  4. Add docstrings and comments

Common Patterns

Pattern Template Use Case
Publisher publisher.py Sending data to topics
Subscriber subscriber.py Receiving data from topics
Service Server (extend publisher) Request/response pattern
Action Server (advanced) Long-running tasks

Node Structure

import rclpy
from rclpy.node import Node

class MyNode(Node):
    def __init__(self):
        super().__init__('node_name')
        # Initialize publishers, subscribers, timers

    def callback(self, msg):
        # Handle incoming messages
        pass

def main(args=None):
    rclpy.init(args=args)
    node = MyNode()
    rclpy.spin(node)
    node.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()

Reference

See messages.md for common message types. See templates/ for complete templates.