Ask Your Question

How do I use pcl::toROSMsg() ?

asked 2013-05-10 07:13:26 -0600

mankoff gravatar image

updated 2013-05-13 05:25:08 -0600

Mac gravatar image

I have a variable world of type const pcl::kinfuLS::WorldModel<pcl::PointXYZI>::PointCloudPtr and I would like to get it into a variable cloud of type sensor_msgs::PointCloud2.

I am trying to use pcl::toROSMsg for this:


But I get the following error message:

pcl/gpu/kinfu_large_scale/src/kinfu.cpp:234:30: error: no matching function for call to ‘toROSMsg(const PointCloudPtr&, sensor_msgs::PointCloud2&)’
pcl/gpu/kinfu_large_scale/src/kinfu.cpp:234:30: note: candidates are:
pcl/common/include/pcl/ros/conversions.h:237:3: note: template<class PointT> void pcl::toROSMsg(const pcl::PointCloud<PointT>&, sensor_msgs::PointCloud2&)
pcl/common/include/pcl/ros/conversions.h:275:3: note: template<class CloudT> void pcl::toROSMsg(const CloudT&, sensor_msgs::Image&)
pcl/common/include/pcl/ros/conversions.h:308:3: note: void pcl::toROSMsg(const sensor_msgs::PointCloud2&, sensor_msgs::Image&)
pcl/common/include/pcl/ros/conversions.h:308:3: note:   no known conversion for argument 1 from ‘const PointCloudPtr {aka const boost::shared_ptr<pcl::PointCloud<pcl::PointXYZI> >}’ to ‘const sensor_msgs::PointCloud2&’

How do I convert between these two data types?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2013-05-10 09:08:37 -0600

According to the compile error messages, the problem is that your arguments are not of the right type. The first argument expects a reference to a PointCloud, and you're passing a PointCloudPtr. You just need to de-reference the shared pointer.

This should work:

edit flag offensive delete link more


Hm. I thought I'd tried de-referencing it, but that does fix it. Thank you!

mankoff gravatar image mankoff  ( 2013-05-10 09:58:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2013-05-10 07:13:26 -0600

Seen: 9,482 times

Last updated: May 10 '13