Ask Your Question
0

PCD files into cloud of points

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

RafMil gravatar image

Hello,

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.

Regards

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

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

Zubin Priyansh gravatar image

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

Comments

1

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 -0500 )edit

Nice! This seems useful too.

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

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

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

Seen: 1,746 times

Last updated: Jun 12 '17