Ask Your Question

toPCL and fromPCLPointCloud2

asked 2014-04-13 01:51:06 -0500

SHPOWER gravatar image


I have a few questions regarding PCL and ros:

What's the difference between toPCL and fromPCLPointCloud2 commands? What's the opposite command to fromPCLPointCloud2? Why can I subscribe to a topic of type sensor_msgs::PointCloud2 with callback of type pcl::PCLPontCloud2ConstPtr?

Is there any source that explains extensively the changes that has been made in hydro version regarding to pcl? All I have found until now was outdated or poorly explained.

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-04-14 08:19:06 -0500

paulbovbel gravatar image


sensor_msgs::PointCloud2 and pcl::PCLPontCloud2 are the message-transport forms of pointclouds, in the ROS and PCL variety. They contain the raw data.

pcl::PointCloud<> is the template form of point clouds that allows you to work with individual points in a more sane manner.

fromPCLPointCloud2 and toPCLPointCloud2 are PCL library functions for conversions. ROS has wrappers for those functions in pcl_conversions/pcl_conversions.h that you should use instead. These will call the right combinations of functions to convert between the message and templated format.

If you include pcl_ros/point_cloud.h, you can avoid doing conversions and subscribe/publish directly with the templated form.

edit flag offensive delete link more


when I type in the terminal: rostopic type /camera/depth_registered/points I got a: sensor_msgs/PointCloud2 then I write in my code: ros::Subscriber sub = nh.subscribe ("/camera/depth_registered/points", 1, cloud_cb); void cloud_cb (const pcl::PCLPointCloud2ConstPtr& cloud){ ... } and I am able to compile the code, why?

SHPOWER gravatar image SHPOWER  ( 2014-04-15 02:43:25 -0500 )edit

That's due to some magic in `pcl_ros/point_cloud.h` I believe. How that works on a ros_comm level would be up to someone more experienced to answer.

paulbovbel gravatar image paulbovbel  ( 2014-04-15 06:46:57 -0500 )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

1 follower


Asked: 2014-04-13 01:51:06 -0500

Seen: 4,037 times

Last updated: Apr 14 '14