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

PCD files into cloud of points

asked 2017-06-11 08:52:12 -0600

RafMil gravatar image


after scanning I have 2 kind of files - some .pcd files and one with .xml extension that is keeping informations about places where .pcd was taken. ROS environment is set up on my workstation (Kinect). Could you give me some hints what should be next steps if I want to get Cloud Point? What i find out is that i should install some PC libraries? Some links may be helpfull as well.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-06-12 06:29:37 -0600

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);

edit flag offensive delete link more



Or just use rosrun pcl_ros pcd_to_pointcloud <file.pcd> [ <interval> ] (from wiki/pcl_ros - pcd_to_pointcloud).

gvdhoorn gravatar image gvdhoorn  ( 2017-06-12 06:49:25 -0600 )edit

Nice! This seems useful too.

Zubin Priyansh gravatar image Zubin Priyansh  ( 2017-06-12 11:50:45 -0600 )edit

@Zubin Priyansh or @gvdhoorn, Can you please suggest same code for python?

askkvn gravatar image askkvn  ( 2020-04-30 07:13:35 -0600 )edit

Question Tools



Asked: 2017-06-11 08:52:12 -0600

Seen: 2,888 times

Last updated: Jun 12 '17