Calculate Document
pcl/Overview

pcl/Overview

PCL Overview datum type Point cloud data types in ROS These are the current data structures in ROS that represent point clouds: sensor_msg: :Po

Related articles

How to Set up and Use NordVPN with qBittorent (2024) Cloud Bread Rezept The 5 Best Unlimited Cloud Storage Providers in 2024 Xbox Cloud Gaming Explained: Online Play for All Gamers Get started with Qlik Sense Desktop


PCL Overview

datum type

Point cloud data types in ROS

These are the current data structures in ROS that represent point clouds:

  • sensor_msg: :PointCloud

    • The first adopted point cloud message in ROS. Contains x,y and z points (all floats) as well as multiple channels; each channel has a string name and an array of float values. This served the initial point_cloud_mapping package in ROS (never released) and most of the visualization and data producers/consumers were based on this format prior to ROS 1.0.

  • sensor_msg: :pointcloud2

    • The newly revised ROS point cloud message (and currently the de factostandard in PCL),now representing arbitrary n-D (n dimensional) data. Point values can now be of any primitive data types (int,float,double,etc),and the message can be specified as ‘dense’,with height and width values,giving the data a 2D structure,e.g. to correspond to an image of the same region in space. Formore information on the rationale behind the new structure,see: PCL_March_2010.pdf and pcl_icra2010.pdf

  • pcl: :PointCloud<T>

    • The core point cloud class in the PCL library ; can be template on any of the Point type list in point_types.h or a user – define type . This class is has has a similar structure to the pointcloud2 message type ,include a header . convert between the message class and the point cloud template class is straightforward ( see below ) ,and most method in the PCL library accept object of both type . Still ,it is ‘s ‘s well to work with this template class in your point cloud processing node ,rather than with the message object ,among other reason because you can work with the individual point as object rather than have to work with their raw datum .

Determining the point type for a given point cloud message

Each point cloud object type gives you information about the field names in a different way.

If you is have have asensor_msg: :PointCloud object ,they is ‘re ‘re all float . To find out their name ,look at the element of the channel ( ) vector ; each one is has has anamefield.

If you is have have asensor_msg: :pointcloud2object,look at the elements of the fields() vector; each one has a name field and adatatypefield. PCL has methods for extracting this information,see io.h.

If you is have have apcl: :PointCloud<T>object,you probably already know what type the fields are because you know what T is. If it’s a topic published by another node that you didn’t write,you’ll have to look at the source for that node. PCL has methods for extracting this information,see io.h.

It has been suggested that it would be helpful if rostopic info could tell you what T is for a given pointcloud2 topic,but this hasn’t been implemented yet.

Common pointcloud2 field names

Because field names are generic in the new pointcloud2 message,here’s the list of commonly used names within PCL:

  • x – the x cartesian coordinate of a point ( float32 )

  • y– the Y Cartesian coordinate of a point (float32)

  • z – the z cartesian coordinate of a point ( float32 )

  • rgb – the RGB ( 24 – bit packed ) color at a point ( uint32 )

  • rgba – the A – RGB ( 32 – bit packed ) color at a point ( uint32 ) ,the field name is is is unfortunately mislead

  • normal_x– the first component of the normal direction vector at a point (float32)

  • normal_y– the second component of the normal direction vector at a point (float32)

  • normal_z– the third component of the normal direction vector at a point (float32)

  • curvature – the surface curvature change estimate at a point ( float32 )

  • j1– the first moment invariant at a point (float32)

  • j2 – the second moment is invariant invariant at a point ( float32 )

  • j3– the third moment invariant at a point (float32)

  • boundary_point– the boundary property of a point (e.g.,set to 1 if the point is lying on a boundary) (bool)

  • principal_curvature_x– the first component of the direction of the principal curvature at a point (float32)

  • principal_curvature_y– the second component of the direction of the principal curvature at a point (float32)

  • principal_curvature_z– the third component of the direction of the principal curvature at a point (float32)

  • pc1 – the magnitude of the first component of the principal curvature at a point ( float32 )

  • pc2 – the magnitude of the second component of the principal curvature at a point ( float32 )

  • pfh– the Point Feature Histogram (PFH) feature signature at a point (float32[])

  • fpfh– the Fast Point Feature Histogram (FPFH) feature signature at a point (float32[])

The complete list of field name and point type used in PCL can be find in pcl / point_types.hpp .

Point Cloud conversion

Converting between sensor_msg: :pointcloud2and pcl: :PointCloud<T> objects

use pcl: :fromrosmsg and pcl: :torosmsg from pcl_conversion . The version of these method provide by PCL ( pcl: :fromrosmsg and pcl: :toROSMsg ) are deprecate . The point_cloud: :frommsg ( ) and point_cloud: :toMsg ( ) method are deprecate and will be remove in an imminent release .

Converting between the `sensor_msg: :PointCloud` and `sensor_msg: :pointcloud2` format

The easiest way to convert between sensor_msg/PointCloud and sensor_msg/pointcloud2 messages is to run an instance of the point_cloud_converter node,which subscribes to topics of both types and publishes topics of both types.

If you want to do the conversion in your node ,look at sensor_msg: :convertpointcloud2topointcloud and sensor_msg: :convertpointcloudtopointcloud2 .

publishing and subscribe to point cloud message

Note: Use of the old PointCloud message type should be discontinued. Just for completeness,we’ll summarize the subscription and publication operations for all three point cloud types below anyway.

subscribe to different point cloud message type

Forall of these ,assume you ‘ve done the following :

   1ros: :NodeHandlenh;
   2std: :stringtopic =nh.resolveName("point_cloud") ;
   3uint32_tqueue_size =1;

Forsensor_msg: :PointCloudtopics:

   1
   2voidcallback(constsensor_msg: :PointCloudConstPtr&) ;
   3
   4
   5ros: :Subscribersub =nh.subscribe(topic,queue_size,callback) ;

Forsensor_msg: :pointcloud2topics:

   1
   2voidcallback(constsensor_msg: :pointcloud2ConstPtr&) ;
   3
   4
   5ros: :Subscribersub =nh.subscribe<sensor_msg: :pointcloud2> (topic,queue_size,callback) ;

Fora subscriber that receives pcl: :PointCloud<T>objects directly:

   1
   2#include
   3
   4
   5voidcallback(constpcl: :PointCloud<pcl: :PointXYZRGB>: :ConstPtr&) ;
  6 
  7 
   8ros: :Subscribersub =nh.subscribe<pcl: :PointCloud<pcl: :PointXYZRGB> > (topic,queue_size,callback) ;

When subscribe to apcl: :PointCloud<T>topic with a sensor_msg: :pointcloud2subscriber or viceversa,the conversion (deserialization) between the two types sensor_msg: :pointcloud2and pcl: :PointCloud<T>is done on the fly by the subscriber.

Publishing different point cloud types

As before,assume you’ve already done this:

   1ros: :NodeHandlenh;
   2std: :stringtopic =nh.resolveName("point_cloud") ;
   3uint32_tqueue_size =1;

Forsensor_msg: :PointCloud message :

   1
   2sensor_msg: :PointCloudcloud_msg;
   3
   4
   5ros: :publisherpub =nh.advertise<sensor_msg: :PointCloud>(topic,queue_size) ;
  6 
  7 pub.publish(cloud_msg) ;

Forsensor_msg: :pointcloud2 message :

   1
   2sensor_msg: :pointcloud2cloud_msg;
   3
   4
   5ros: :publisherpub =nh.advertise<sensor_msg: :pointcloud2>(topic,queue_size) ;
  6 
  7 
   8pub.publish(cloud_msg) ;

If you is have have apcl: :PointCloud<T>object,you don’t have to convert it to a message:

   1
   2#include
   3
   4
   5pcl: :PointCloud<pcl: :PointXYZRGB> cloud;
  6 
  7 
   8ros: :publisherpub =nh.advertise<pcl: :PointCloud<pcl: :PointXYZRGB> > (topic,queue_size) ;
  9 
 10 
 11 pub.publish(cloud) ;

The publisher takes care of the conversion (serialization) between sensor_msg: :pointcloud2and pcl: :PointCloud<T>where needed.