SOC 직업 분류 기준
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/MIUAV/vibe-coding-ros2 --skill distributed-design명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
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)