Ask Your Question

Standard for PointCloud messages is still PointCloud2?

asked 2012-12-12 02:23:19 -0500

Kilin gravatar image


After some work with standalone PCL, I'm running the first tests of PCL under ROS.

I have a question: I understand that pcl::PointCloud<t> is the preferred type for point clouds, and I was able to register a callback to kinect streams using just this type (without conversions to/from sensor_msgs::PointCloud2)

Now I was trying to implement a service that returns PointClouds. In order to define a service I need to specify a message type, and I only see sensor_msgs/PointCloud and PointCloud2.

My question is: this means that PointCloud2 is still the preferred standard for PointCloud messages, or am I missing a more specific message type that allows to handle pcl::PointCloud<t> arguments?

Should I always work with sensor_msgs/PointCloud2 messages when playing with services, and perform conversions to pcl::PointCloud<t> inside my code?

thank you

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-12-12 09:32:07 -0500

Miguel S. gravatar image

Short answer, yes. sensor_msgs/PointCloud2 is the message type to transmit point clouds; if you want to do pcl processing with them you'll need to convert them to pcl::PointCloud<T> using pcl::fromROSMsg and pcl::toROSMsg.

For the long answer, see the (ROS/PCL overview) and the (tutorial). As indicated on the latter:

The sensor_msgs/PointCloud2 format was designed as a ROS message, and is the preferred choice for ROS applications.

The pcl/PointCloud<T> format represents the internal PCL point cloud format. For modularity and efficiency reasons, the format is templated on the point type, and PCL provides a list of templated common types which are SSE aligned.

Hope it helps!

edit flag offensive delete link more


With Hydro and the introduction of `pcl::PCLPointCloud2` (as well as automatic serializers to convert b/w types), is this still true? Does `pcl::PCLPointCloud2` trump `pcl::PointCloud<t>`?

Neil Traft gravatar image Neil Traft  ( 2014-07-24 01:20:27 -0500 )edit

answered 2012-12-12 09:51:16 -0500

Kilin gravatar image

Hi Miguel, thank you for your reply! Well, so it seems that I must keep these ugly conversions :-/

For what I understood, the PointCloud2 is good since it is a "raw" format, so every custom PointCloud<t> can be mapped on it... that is consistent.

However, in my humble opinion, it could be nice if at least for the more common types (e.g. XYZRGB) we could have messages that allows us to avoid copies.

edit flag offensive delete link more


This should have been a comment on the above answer, not a separate answer.

Neil Traft gravatar image Neil Traft  ( 2014-07-24 01:16:07 -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: 2012-12-12 02:23:19 -0500

Seen: 1,394 times

Last updated: Dec 12 '12