ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Need PCL conversion help

asked 2015-06-04 16:06:31 -0600

rnunziata gravatar image

updated 2015-06-04 18:04:42 -0600

Can not figure out how to convert with toROSMsg : is there another conversion function?

get error:

/opt/ros/indigo/include/pcl_conversions/pcl_conversions.h:486:8: note:   no known conversion for argument 1 from ‘pcl::PointCloud<pcl::PointXYZRGBA>’ to ‘const PointCloud2& {aka const sensor_msgs::PointCloud2_<std::allocator<void> >&}’
/opt/ros/indigo/include/pcl_conversions/pcl_conversions.h:508:8: note: template<class T> void pcl::toROSMsg(const pcl::PointCloud<PointT>&, sensor_msgs::PointCloud2&)
   void toROSMsg(const pcl::PointCloud<T> &pcl_cloud, sensor_msgs::PointCloud2 &cloud)

the code is as follows;

    sensor_msgs::PointCloud2 pc2;
    pcl::toROSMsg(*cloud_pass_downsampled_, &pc2);

This code compiles:

pcl::PointCloud<pcl::PointXYZ> mycloud;
pcl::copyPointCloud(*cloud_pass_downsampled_, mycloud);
sensor_msgs::PointCloud2 pc2;
pcl::toROSMsg(mycloud, pc2);
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2015-06-04 18:20:21 -0600

nitekrawler gravatar image

updated 2015-06-04 18:20:50 -0600

This is what I usually do:

pcl::PointCloud<pcl::PointXYZ>::Ptr final(new pcl::PointCloud<pcl::PointXYZ>);
*do something*
sensor_msgs::PointCloud2 output;
pcl::PCLPointCloud2 tmp_cloud;
pcl::toPCLPointCloud2(*final, tmp_cloud);
pcl_conversions::fromPCL(tmp_cloud, output);
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-06-04 16:06:31 -0600

Seen: 929 times

Last updated: Jun 04 '15