[ros-users] PointCloud2 and Point Cloud Library (PCL)

Radu Bogdan Rusu rusu at willowgarage.com
Fri Apr 2 18:18:20 UTC 2010

Hi all,

To avoid further confusion about the new PointCloud2 message format and the new library that is currently being
developed, PCL (Point Cloud Library), here's a few notes on what's going on. Before you dive into them please note that 
we are working hard at creating a set of usable tutorials and examples, to alleviate PCL's learning curve. Just check 
the wiki page regularly for updates (http://www.ros.org/wiki/pcl). :) Also don't be shy in contributing if you're 
interested in 3D perception. ;) Thanks!

Note: Though PointCloud2 has been reviewed and released, PCL is still undergoing developmental changes, and it will take 
some time until we will have a formal review and a 1.0 "stable" release. The officially supported format for point cloud 
data in ROS is still PointCloud, as we have developed a lot of tools to deal with that. However, users and developers 
interested in all the new 3D processing algorithms that we are developing, will need to get PCL. Feel free to contact me 
(or any of my colleagues working on PCL) for help or if you get stuck somewhere, but again, please note, that this stuff 
is bleeding edge ;)

The reason behind the developments of PointCloud2/PCL are "quad-fold" :)

1) The PointCloud message format was inefficient for several things. It wasn't properly aligned (e.g., SSE), it had a 
large overhead, it could only support extra dimensions/channels/fields as floats, etc.

2) point_cloud_mapping was a C library. Easy to use for simple stuff, but hard for building more complicated behaviors. 
Working on the doors and handle detection in Mileston2 was a good example, where the code was starting to get really messy.

3) In a way, because of 2, it wasn't too easy to build components which could be easily reused. We had bits and pieces 
all over the place, doing segmentation, feature estimation, or other stuff, having basically the same code, but without 
reusing what has been written already.

4) PointClouds are unfortunately the most intensive data packages in ROS. They are the largest (or can be), and you want 
to apply all sorts of "reusable" operations on them. Copying data around therefore proved to be a real pain, and was 
slowing down the entire system.

The solutions adopted are:

1) We transformed the PointCloud into a binary blob (and named it PointCloud2), similar to the way Images are 
represented in ROS. We have ways of representing dense data now, as well as a secondary templated PointCloud<PointT> 
format, in which we can automatically convert the data depending on what the user wants PointT to represent. You want 
XYZRGBA? Just use pcl::PointCloud<pcl::PointXYZRGBA>, etc.

This makes the format very light and extremely efficient for alignment and SSE operations (more on that later).

2) PCL is designed as a fully fledged C++ API, with a few C/static methods for those small things that you need but 
don't want to instantiate an object for. In addition, we're using templates and inheritance everywhere, and everything 
is being passed internally through boost shared pointers. There's lots of other things as well, like the Eigen backend 
for SSE optimizations, OpenMP and TBB for parallelization, dynamic_reconfigure for setting parameters on the fly, etc. 
We'll write an e-book about it when it's all done and mature :)

Designing a new feature and plugging into the library should take 5 minutes, as should a new segmentation or 
registration algorithm.

3) We have developed a new ROS concept for PCL, called nodelets. They are the per process equivalent of multiple nodes. 
They look like nodes, they talk like nodes, and they act like nodes. :) Except they're all in a single process. They use 
publish/subscribe, and we made a few ROS optimizations to allow zero-copies for boost shared pointers when used in the 
same process. However, once you start two nodes, each containing a nodelet, the data is copied automatically, since 
we're using the same Publish/Subscribe API. [note: nodelets are not part of PCL and can be used elsewhere. To learn more 
about nodelets check the mailing list archive and the nodelets wiki page at http://www.ros.org/wiki/nodelet]

PCL is under continuous development, and you can check more about it at http://www.ros.org/wiki/pcl. I also uploaded a 
set of slides that were used during the kickoff PCL meeting at Willow Garage a few weeks ago. Please note however that 
since the library is undergoing heavy development, some of the information provided in the slides might not be up to 
date. Once the API stabilizes a bit more, we will generate a new set of slides (a bit more technical) that describe the 
inner workings, list all the algorithms inside, etc.

Feel free to e-mail about any question you might have. :)

PS. Big thanks to my colleagues at TUM for helping out in kickstarting PCL!

| Radu Bogdan Rusu | http://rbrusu.com/

More information about the ros-users mailing list