Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/MIUAV/vibe-coding-ros2 --skill multi-sensor-timesync명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
| name | multi-sensor-timesync |
| description | 多传感器时间同步技能 - 硬件同步、软同步、NTP、ROS2 时间同步 |
| argument-hint | 时间同步 OR hardware sync OR NTP OR timesync |
| user-invocable | true |
多传感器时间同步方案
当需要以下帮助时使用此技能:
# 硬件同步配置 (激光雷达 + 相机)
hardware_config:
lidar:
model: Velodyne VLP-16
mode: phase_lock # 相位锁定
sync_frequency: 10 # Hz
phase_offset: 0.0 # 秒
camera:
model:_basalt
trigger_mode: hardware_external
trigger_delay: 0.002 # 2ms 硬件延迟
gps_imu:
model: XSens MTi
sync_mode: time_ins
import rclpy
from rclpy.node import Node
from message_filters import Subscriber, ApproximateTimeSynchronizer
from sensor_msgs.msg import Image, PointCloud2, Imu
from geometry_msgs.msg import PoseWithCovarianceStamped
class MultiSensorSyncNode(Node):
def __init__(self):
super().__init__('multi_sensor_sync')
# 创建同步订阅
self.image_sub = Subscriber(self, Image, '/camera/image_raw')
self.lidar_sub = Subscriber(self, PointCloud2, '/lidar/points')
self.imu_sub = Subscriber(self, Imu, '/imu/data')
self.gps_sub = Subscriber(self, PoseWithCovarianceStamped, '/gps/pose')
# 时间同步器
self.sync = ApproximateTimeSynchronizer(
[self.image_sub, self.lidar_sub, self.imu_sub],
queue_size=20,
slop=0.05 # 50ms 容差
)
self.sync.registerCallback(self.sync_callback)
def sync_callback(self, image, lidar, imu):
stamp = image.header.stamp
.process_data(image, lidar, imu)
import numpy as np
class TimeSynchronizer:
"""软件时间同步"""
def __init__(self, buffer_size=10):
self.buffer_size = buffer_size
self.timestamps = {
'camera': [],
'lidar': [],
'imu': []
}
self.offsets = {
'lidar_camera': 0.0,
'imu_camera': 0.0
}
def add_timestamp(self, sensor, stamp):
"""添加时间戳"""
self.timestamps[sensor].append(stamp)
if len(self.timestamps[sensor]) > self.buffer_size:
self.timestamps[sensor].pop(0)
# 估计偏移
self.estimate_offset()
def estimate_offset(self):
"""估计传感器间时间偏移"""
# 互相关估计
for s1, s2 in [('lidar', 'camera'), ('imu', 'camera')]:
if len(self.timestamps[s1]) > 5 (.timestamps[s2]) > :
offset = .compute_offset(
.timestamps[s1],
.timestamps[s2])
.offsets[] = offset
():
diffs = []
t1 times1:
closest = (times2, key= t2: (t2 - t1))
diffs.append(t1 - closest)
np.median(diffs)
():
sensor == :
stamp - .offsets[]
sensor == :
stamp - .offsets[]
stamp
# 配置 PTP (Precision Time Protocol)
# 交换机需要支持 PTP
# 查看网卡是否支持 PTP
ethtool -T eth0
# 启用 PTP
sudo ptp4l -i eth0 -m &
SOC 직업 분류 기준