用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/MIUAV/vibe-coding-ros2 --skill distributed-design命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | distributed-design |
| description | 分布式设计技能 - 多机通信、时钟同步、数据分发、边缘计算架构 |
| argument-hint | 分布式 OR distributed OR multi-machine OR 时钟同步 OR edge |
| user-invocable | true |
分布式机器人系统设计
当需要以下帮助时使用此技能:
# distributed_node.py
import rclpy
from rclpy.node import Node
from rclpy.executors import MultiThreadedExecutor
import threading
class DistributedNode(Node):
def __init__(self, node_name, namespace=None):
super().__init__(node_name, namespace=namespace)
# 跨机器通信
self.declare_parameter('master_uri', 'http://192.168.1.100:11311')
self.declare_parameter('robot_id', 1)
# 数据分发
self.publisher_map = {}
self.subscription_map = {}
def create_cross_machine_publisher(self, topic, msg_type):
"""创建跨机器发布者"""
pub = self.create_publisher(msg_type, topic, 10)
self.publisher_map[topic] = pub
return pub
def create_cross_machine_subscription(self, topic, msg_type, callback):
"""创建跨机器订阅"""
sub = self.create_subscription(msg_type, topic, callback, 10)
self.subscription_map[topic] = sub
return sub
class ClockSynchronizer:
def __init__(self):
self.offset = 0.0
self.samples = []
def add_sample(self, local_time, remote_time):
"""添加时间同步样本"""
self.samples.append((local_time, remote_time))
if len(self.samples) > 10:
# 计算偏移
self.compute_offset()
def compute_offset(self):
"""计算时钟偏移"""
if len(self.samples) < 3:
return
# 使用中位数
offsets = [remote - local for local, remote in self.samples]
offsets.sort()
self.offset = offsets[len(offsets) // 2]
def remote_to_local(self, remote_time):
"""远程时间转本地时间"""
return remote_time - self.offset
# 机器 A
export ROS_DOMAIN_ID=42
export ROS_IP=192.168.1.100
ros2 run package node_a
# 机器 B
export ROS_DOMAIN_ID=42
export ROS_IP=192.168.1.101
ros2 run package node_b
class DataDistributionService:
def __init__(self):
self.nodes = {} # node_id -> NodeInfo
def register_node(self, node_id, capabilities):
"""注册节点"""
self.nodes[node_id] = {
'capabilities': capabilities,
'last_heartbeat': time.time()
}
def publish_data(self, source_id, data_type, payload):
"""发布数据到所有订阅者"""
for node_id, info in self.nodes.items():
if node_id != source_id:
if data_type in info['capabilities']:
self.send_to_node(node_id, data_type, payload)