Publishing a vector of point clouds
I successfully published pointclouds by converting them to ROSMsg. But is it somehow possible to publish a vector containing multiple pointclouds?
I tried this:
pcl::PointCloud<ClassPoint> out;
....
sensor_msgs::PointCloud2 out_msg;
pcl::toROSMsg(out, out_msg);
std::vector<sensor_msgs::PointCloud2> clouds(2);
clouds[0] = out_msg;
out_msg.header.frame_id = corner_frame_name;
pub_merged_clouds.publish(clouds);
while I got
pub_merged_clouds = nh.advertise<std::vector<sensor_msgs::PointCloud2>>(merged_clouds_topic, 1);
This unfortunately doesn't work. I get the following error when compiling
error: ‘const class std::vector<sensor_msgs::PointCloud2_<std::allocator<void> > >’ has no member named ‘__getMD5Sum’
return m.__getMD5Sum().c_str();
Is there a way to do this? Thanks alot!
You need to define a new message type containing an array of pointclouds.
@stevemacenski Thank you for you reply. Could you elaborate? How exactly can I create an own sensor_msgs type?
To add on to @stevemacenski's comment, have a look at ROS tutorial . The custom msg will have an array of
sensor_msgs::PointCloud2
, e.g. in afilename.msg
,sensor_msgs/PointCloud2[ ] clouds
. Then, in your code declarepackagename::filename clouds
andclouds.push_back(cloud)
each cloud. Include the new header file for the custom msg in your code. It would be better to build the new msg package first then your other package.