ROS2 xyz numpy to topic

OpenJR·2025년 3월 27일
def publish_pointcloud(self, xyz1: np.ndarray):
    # xyz1: shape (N, 4)
    points_xyz = xyz1[:, :3]  # (x, y, z)만 사용

    header = Header()
    header.stamp = self.get_clock().now().to_msg()
    header.frame_id = "mylink"  # 또는 "base_link", 사용하고 싶은 TF frame

    cloud_msg = point_cloud2.create_cloud_xyz32(header, points_xyz)
    self.pc_publisher.publish(cloud_msg)
profile
Jacob

0개의 댓글