ROS2 Service & Action

Implements ROS2 services and actions in Python and C++ following Clean Architecture.

Updated Aug 16, 2026
One-click install
npx skills add https://github.com/three1324/yeonjinautomotive --skill ros2-service-action-three1324
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ROS2 Service & Action
Source: https://github.com/three1324/yeonjinautomotive/tree/main/.claude/skills/ros2_service_action
Command: npx skills add https://github.com/three1324/yeonjinautomotive --skill ros2-service-action-three1324

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Structuring ROS2 Service and Action code so that business logic stays decoupled from the ROS2 middleware is difficult, and ad-hoc implementations quickly become untestable and hard to maintain. This Skill provides ready-to-adapt templates that enforce Clean Architecture layering. ## Core Features & Use Cases - Service Implementation: Defines .srv interfaces and implements service servers and async clients in both Python and C++, with the infrastructure layer delegating to domain use cases. - Action Implementation: Defines .action interfaces with goal, result, and feedback, and implements action servers (goal/cancel/execute handlers) and clients with feedback callbacks in C++. - Use Case: When building a robot that must expose a mode-switching service and a long-running navigation action, use this Skill to scaffold the interface definitions, rclcpp/rclpy nodes, and use-case wiring without mixing ROS types into domain logic. ## Quick Start Ask the AI to implement a ROS2 service and action for your robot using Clean Architecture with separate domain use cases and infrastructure nodes.

Frequently Asked Questions about ROS2 Service & Action

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a ROS2 service server in C++?

Create a node class inheriting from rclcpp::Node and call create_service with the .srv type, topic name, and a callback binding request and response. The callback should delegate to a domain use case and map its result onto the response fields.

How to create a ROS2 action server with feedback?

Use rclcpp_action::Server with handle_goal, handle_cancel, and handle_accepted callbacks, then run execute in a separate thread that publishes feedback via the goal handle. Define goal, result, and feedback sections in the .action file first.

What is the difference between ROS2 services and actions?

Services are synchronous request-response interactions for short tasks, while actions are asynchronous goal-based interfaces for long-running tasks that provide periodic feedback and support cancellation. Choose services for quick queries and actions for navigation or motion goals.

Can ROS2 services and actions follow Clean Architecture?

Yes, by placing service and action nodes in an infrastructure layer that converts ROS messages to domain objects and calls injected use case classes. This keeps business logic free of rclcpp or rclpy dependencies and independently testable.

Does this approach support both Python and C++ ROS2 nodes?

Yes, the patterns cover rclpy for Python service servers and rclcpp for C++ service servers, clients, and action servers. Both languages share the same layering principle of isolating use cases from middleware code.