Conversion from sensor_msgs::PointCloud2 to pcl::PointCloud<T>
Hi all, I am digging deep in this forum, but I'm getting lost. I am using ROS Groovy and receiving a sensor_msgs::PointCloud2 from a depth_image_proc nodelet and I want to process it using PCL 1.7. None of the solutions found in this forum are working for me, i.e., I miss some function prototype of toPCL, fromROSMsg, etc. functions.
I would like to do something like:
void CloudViewerPlugin::pointcloudCallback(const sensor_msgs::PointCloud2::ConstPtr& msg) {
pcl::PointCloud<pcl::PointXYZ> cloud;
pcl::PCLPointCloud2 pcl_pc;
pcl_conversions::toPCL(*msg, pcl_pc);
pcl::fromPCLPointCloud2(pcl_pc, cloud);
or
void CloudViewerPlugin::pointcloudCallback(const sensor_msgs::PointCloud2::ConstPtr& msg) {
pcl::PointCloud<pcl::PointXYZ> cloud;
pcl::fromROSMsg(*msg, cloud);
but I found no function prototype to do this.
Can you try to directly subscribe to a pcl pointcloud? There might be some pcl_ros magic going on that allows you to do so.
Hi Christian, I already tried that solution, but: /opt/ros/groovy/include/ros/message_traits.h:121: error: ‘__s_getMD5Sum’ is not a member of ‘pcl::PointCloud<pcl::pointxyz>’ on the subscribe line (I'm following http://wiki.ros.org/pcl_ros)
Sorry, I hadn't #included the right files, however, now there are two errors: /opt/ros/groovy/include/pcl_ros/point_cloud.h:176: error: no matching function for call to ‘createMapping(std::vector<sensor_msgs::pointfield_<std::allocator<void> > >&, pcl::MsgFieldMap&)’ and: /opt/ros/groovy/include/ros/serialization.h:134: error: ‘struct pcl::PCLHeader’ has no member named ‘deserialize’
I believe your second option
fromRosMsg
is only available fron Kinetic onwards