ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The issue is that the pcl::toROSMsg(const pcl::PointCloud<...>, sensor_msgs::PointCloud2) function overwrites the header in the destination sensor_msgs::PointCloud2 object with the header in the pcl::PointCloud<...> object, effective overwriting the values you set in the first few lines of your loop:

http://docs.pointclouds.org/1.7.0/conversions_8h_source.html#l00237

You can simply move the setting of the timestamp and frame id to after you call pcl::toROSMsg.