AgentSkillsCN

concurrency-ros2

ROS 2(rclcpp/rclpy)并发开发指南:执行器、回调组、服务/动作/定时器,以及避免死锁的安全模式。在修改 ROS 节点或回调函数时务必参考此指南。

SKILL.md
--- frontmatter
name: concurrency-ros2
description: "ROS 2 (rclcpp/rclpy) concurrency guidance: executors, callback groups, services/actions/timers, and deadlock-safe patterns. Use when modifying ROS nodes or callbacks."
metadata:
  short-description: ROS 2 concurrency patterns

Purpose

Make ROS callbacks safe, non-blocking where needed, and deadlock-resistant.

When to use

Use this skill when touching:

  • rclcpp/rclpy nodes or executors
  • callback groups
  • services, actions, or timers

How to use

  1. Open references/concurrency-ros2.md.
  2. Choose executor strategy (SingleThreaded vs MultiThreaded) and justify.
  3. Choose callback group layout; explicitly separate blocking/synchronous paths.
  4. Identify synchronous service/client calls inside callbacks; apply deadlock rules.
  5. Move heavy work off callback threads when needed (worker thread / queue).
  6. Add observability hooks for callbacks and queues (length, latency).
  7. Define verification (stress + race tooling if multi-threaded).

Output expectation

  • Add a ROS2 Concurrency Notes section to the Concurrency Plan.