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

Revision history [back]

Take a look at the PCL Ros tutorials. There is nothing special about PCL, it can be used as any third-party library.

You will get your potincloud messages in ROS as sensor_msgs::Pointcloud2. But in the tutorials they explain how to convert this to PCL pointcloud type:

pcl::PointCloud<pcl::PointXYZ> cloud;
pcl::fromROSMsg (*input, cloud);

You can find more information about how to convert types here. Note that an awesome feature is what is explained at the end of section 3.1:

// Need to include the pcl ros utilities
#include "pcl_ros/point_cloud.h"

// callback signature, assuming your points are pcl::PointXYZRGB type:
void callback(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&);

// create a templated subscriber
ros::Subscriber sub = nh.subscribe<pcl::PointCloud<pcl::PointXYZRGB> > (topic, queue_size, callback);

That is, ROS includes some hooks so that you can subscribe directly to the PCL pointcloud type and thus you do not need to carry out any conversion.