Skip to content

Commit bf274dd

Browse files
committed
cloud not on private node handle
1 parent 405959c commit bf274dd

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

include/patchworkpp/patchworkpp.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ void PatchWorkpp<PointT>::estimate_ground(
462462
unique_lock<recursive_mutex> lock(mutex_);
463463

464464
poly_list_.header.stamp = ros::Time::now();
465+
poly_list_.header.frame_id = cloud_in.header.frame_id;
465466
if (!poly_list_.polygons.empty()) poly_list_.polygons.clear();
466467
if (!poly_list_.likelihood.empty()) poly_list_.likelihood.clear();
467468

@@ -658,27 +659,27 @@ void PatchWorkpp<PointT>::estimate_ground(
658659
sensor_msgs::PointCloud2 cloud_ROS;
659660
pcl::toROSMsg(revert_pc_, cloud_ROS);
660661
cloud_ROS.header.stamp = ros::Time::now();
661-
cloud_ROS.header.frame_id = "map";
662+
cloud_ROS.header.frame_id = cloud_in.header.frame_id;
662663
pub_revert_pc.publish(cloud_ROS);
663664

664665
pcl::toROSMsg(reject_pc_, cloud_ROS);
665666
cloud_ROS.header.stamp = ros::Time::now();
666-
cloud_ROS.header.frame_id = "map";
667+
cloud_ROS.header.frame_id = cloud_in.header.frame_id;
667668
pub_reject_pc.publish(cloud_ROS);
668669

669670
pcl::toROSMsg(normals_, cloud_ROS);
670671
cloud_ROS.header.stamp = ros::Time::now();
671-
cloud_ROS.header.frame_id = "map";
672+
cloud_ROS.header.frame_id = cloud_in.header.frame_id;
672673
pub_normal.publish(cloud_ROS);
673674

674675
pcl::toROSMsg(noise_pc_, cloud_ROS);
675676
cloud_ROS.header.stamp = ros::Time::now();
676-
cloud_ROS.header.frame_id = "map";
677+
cloud_ROS.header.frame_id = cloud_in.header.frame_id;
677678
pub_noise.publish(cloud_ROS);
678679

679680
pcl::toROSMsg(vertical_pc_, cloud_ROS);
680681
cloud_ROS.header.stamp = ros::Time::now();
681-
cloud_ROS.header.frame_id = "map";
682+
cloud_ROS.header.frame_id = cloud_in.header.frame_id;
682683
pub_vertical.publish(cloud_ROS);
683684
}
684685

src/demo.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,18 @@ void callbackCloud(const sensor_msgs::PointCloud2::Ptr &cloud_msg)
4949
int main(int argc, char**argv) {
5050

5151
ros::init(argc, argv, "Demo");
52-
ros::NodeHandle nh("~");
52+
ros::NodeHandle nh;
53+
ros::NodeHandle pnh("~");
5354

5455
std::string cloud_topic;
55-
nh.param<string>("cloud_topic", cloud_topic, "/pointcloud");
56+
pnh.param<string>("cloud_topic", cloud_topic, "/pointcloud");
5657

5758
cout << "Operating patchwork++..." << endl;
58-
PatchworkppGroundSeg.reset(new PatchWorkpp<PointType>(&nh));
59+
PatchworkppGroundSeg.reset(new PatchWorkpp<PointType>(&pnh));
5960

60-
pub_cloud = nh.advertise<sensor_msgs::PointCloud2>("cloud", 100, true);
61-
pub_ground = nh.advertise<sensor_msgs::PointCloud2>("ground", 100, true);
62-
pub_non_ground = nh.advertise<sensor_msgs::PointCloud2>("nonground", 100, true);
61+
pub_cloud = pnh.advertise<sensor_msgs::PointCloud2>("cloud", 100, true);
62+
pub_ground = pnh.advertise<sensor_msgs::PointCloud2>("ground", 100, true);
63+
pub_non_ground = pnh.advertise<sensor_msgs::PointCloud2>("nonground", 100, true);
6364

6465
ros::Subscriber sub_cloud = nh.subscribe(cloud_topic, 100, callbackCloud);
6566

0 commit comments

Comments
 (0)