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

Revision history [back]

If your have installed ROS desktop successfully, you don't need to install PCL separately. You will notice that a package named pcl_ros is already installed on your computer. Reffering this link you can see that you can load a PCD file and then publish it on a topic in the following dummy code:

#include <pcl/io/pcd_io.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>

...

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
if (pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud) == -1) //* load the file
  {
    PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
    return (-1);
  }

  ros::Publisher pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
  sensor_msgs::PointCloud2 output;
  pcl::toROSMsg(*cloud, output);
  pub.publish (output);

...