情景:
正在做PCL点云的开发,目的就是要把目标检测到的点云在rviz上显示。但是,明明搞好了发布,所有该有的东西都全了,rviz找到topic,却显示frame error。
修改前的代码如下
rmaCloudOutMsg.header.stamp = laser_cloud_msg.header.stamp;
rmaCloudOutMsg.header.frame_id = "camera_init";
pcl::toROSMsg(laser_cloud, rmaCloudOutMsg);
rmaCloudPublisher.publish(rmaCloudOutMsg);
后来我想到!是不是顺序的问题。也就是toROSMsg这个过程把原本有的header清除掉了。
修改代码如下:
pcl::toROSMsg(laser_cloud, rmaCloudOutMsg);
rmaCloudOutMsg.header.stamp = laser_cloud_msg.header.stamp;
rmaCloudOutMsg.header.frame_id = "camera_init";
rmaCloudPublisher.publish(rmaCloudOutMsg);
现在成功解决!