Rosanswers logo

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);

Originally posted by rnunziata on ROS Answers with karma: 713 on 2015-06-04

Post score: 0


1 Answer 1


Rosanswers logo

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);

Originally posted by nitekrawler with karma: 93 on 2015-06-04

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.