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

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:

pcl::toROSMsg(world,cloud);

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
7

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:

pcl::toROSMsg(*world,cloud);
edit flag offensive delete link more

Comments

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

Question Tools

2 followers

Stats

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

Seen: 13,567 times

Last updated: May 10 '13