- 发布point cloud点云的消息处理
就是定义消息,填充消息中数值,进行发布。
sensor_msgs::PointCloud cloud;
cloud.header.stamp = ros::Time::now();
cloud.header.frame_id = "Frame";
cloud.points.resize(nums_point_cloud);
cloud.channels.resize(2);
cloud.channels[0].name = "intensity";
cloud.channels[0].values.resize(nums_point_cloud);
cloud.channels[1].name = "distance";
cloud.channels[1].values.resize(nums_point_cloud);
while (i++ < nums_point_cloud)
{
cloud.points[i].x = x;
cloud.points[i].y = y;
cloud.points[i].z = z;
cloud.channels[0].values[i] = r;
cloud.channels[1].values[i] = d;
}
msg_pub->publish(cloud);