Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/MIUAV/vibe-coding-ros2 --skill spatial-temporal-sync명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | spatial-temporal-sync |
| description | 时空同步技能 - 硬件同步、软件同步、时间戳对齐、外参标定 |
| argument-hint | 时间同步 OR hardware sync OR temporal sync OR spatial sync |
| user-invocable | true |
多传感器时间同步与空间对齐
当需要以下帮助时使用此技能:
# 硬件同步配置示例
hardware_sync:
# GPS + IMU 同步
gps_imu_sync:
trigger_mode: external_interrupt
frequency: 100 # Hz
offset_ns: 0
# 激光雷达 + 相机同步
lidar_camera_sync:
trigger_mode: time_based
phase_offset: 0.05 # 50ms 相位偏移
import rclpy
from rclpy.node import Node
from message_filters import Subscriber, ApproximateTimeSynchronizer
from sensor_msgs.msg import Image, PointCloud2, Imu
from cv_bridge import CvBridge
class SensorSyncNode(Node):
def __init__(self):
super().__init__('sensor_sync_node')
self.bridge = CvBridge()
# 创建订阅者
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.sync = ApproximateTimeSynchronizer(
[self.image_sub, self.lidar_sub, self.imu_sub],
queue_size=10,
slop=0.1 # 100ms 容差
)
self.sync.registerCallback(self.sync_callback)
# 发布同步后的话题
self.synced_pub = self.create_publisher(PointCloud2, '/synced/lidar', 10)
():
stamp = image_msg.header.stamp
.get_logger().info()
projected = .project_lidar_to_image(lidar_msg, image_msg)
.synced_pub.publish(projected)
():
K = np.array([, , , , , , , , ]).reshape(, )
T_lidar_cam = np.eye()
points = .parse_pointcloud(lidar_msg)
points_hom = np.hstack([points, np.ones(((points), ))])
points_cam = (T_lidar_cam @ points_hom.T).T
valid = points_cam[:, ] >
points_cam = points_cam[valid]
points_2d = (K @ points_cam[:, :].T).T
points_2d[:, ] /= points_2d[:, ]
points_2d[:, ] /= points_2d[:, ]
points_2d[:, :]
import numpy as np
class ExtrinsicCalibrator:
def __init__(self):
self.T_lidar_cam = np.eye(4) # 激光雷达到相机的变换
def calibrate(self, lidar_corners, camera_corners):
"""
基于标定板的 extrinsic calibration
lidar_corners: 激光雷达检测到的角点 (N, 3)
camera_corners: 图像中检测到的角点 (N, 2)
K: 相机内参矩阵
"""
# 使用 PnP 求解
# 3D-2D 对应关系
pass
def refine_calibration(self, observations):
"""非线性优化 refinement"""
# Ceres solver 或 g2o 优化
pass
def validate_calibration(self, test_lidar, test_image):
"""验证标定精度"""
# 投影测试点
projected = self.project_lidar_to_camera(test_lidar)
# 计算重投影误差
error = np.linalg.norm(projected - test_image, axis=1)
return error.mean(), error.std()