@@ -19,9 +19,10 @@ ros::Publisher pub_ground;
1919ros::Publisher pub_non_ground;
2020
2121template <typename T>
22- sensor_msgs::PointCloud2 cloud2msg (pcl::PointCloud<T> cloud, std::string frame_id = " map" ) {
22+ sensor_msgs::PointCloud2 cloud2msg (pcl::PointCloud<T> cloud, const ros::Time& stamp, std::string frame_id = " map" ) {
2323 sensor_msgs::PointCloud2 cloud_ROS;
2424 pcl::toROSMsg (cloud, cloud_ROS);
25+ cloud_ROS.header .stamp = stamp;
2526 cloud_ROS.header .frame_id = frame_id;
2627 return cloud_ROS;
2728}
@@ -38,12 +39,12 @@ void callbackCloud(const sensor_msgs::PointCloud2::Ptr &cloud_msg)
3839
3940 PatchworkppGroundSeg->estimate_ground (pc_curr, pc_ground, pc_non_ground, time_taken);
4041
41- cout << " \033 [1;32m" << " Result: Input PointCloud: " << pc_curr.size () << " -> Ground: " << pc_ground.size () << " / NonGround: " << pc_non_ground.size ()
42- << " (running_time: " << time_taken << " sec)" << " \033 [0m" << endl ;
42+ ROS_INFO_STREAM ( " \033 [1;32m" << " Input PointCloud: " << pc_curr.size () << " -> Ground: " << pc_ground.size () << " / NonGround: " << pc_non_ground.size ()
43+ << " (running_time: " << time_taken << " sec)" << " \033 [0m" ) ;
4344
44- pub_cloud.publish (cloud2msg (pc_curr, cloud_msg->header .frame_id ));
45- pub_ground.publish (cloud2msg (pc_ground, cloud_msg->header .frame_id ));
46- pub_non_ground.publish (cloud2msg (pc_non_ground, cloud_msg->header .frame_id ));
45+ pub_cloud.publish (cloud2msg (pc_curr, cloud_msg->header .stamp , cloud_msg-> header . frame_id ));
46+ pub_ground.publish (cloud2msg (pc_ground, cloud_msg->header .stamp , cloud_msg-> header . frame_id ));
47+ pub_non_ground.publish (cloud2msg (pc_non_ground, cloud_msg->header .stamp , cloud_msg-> header . frame_id ));
4748}
4849
4950int main (int argc, char **argv) {
0 commit comments