@@ -19,9 +19,10 @@ ros::Publisher pub_ground;
19
19
ros::Publisher pub_non_ground;
20
20
21
21
template <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" ) {
23
23
sensor_msgs::PointCloud2 cloud_ROS;
24
24
pcl::toROSMsg (cloud, cloud_ROS);
25
+ cloud_ROS.header .stamp = stamp;
25
26
cloud_ROS.header .frame_id = frame_id;
26
27
return cloud_ROS;
27
28
}
@@ -38,12 +39,12 @@ void callbackCloud(const sensor_msgs::PointCloud2::Ptr &cloud_msg)
38
39
39
40
PatchworkppGroundSeg->estimate_ground (pc_curr, pc_ground, pc_non_ground, time_taken);
40
41
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" ) ;
43
44
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 ));
47
48
}
48
49
49
50
int main (int argc, char **argv) {
0 commit comments