0
$\begingroup$

Rosanswers logo

How to process point clouds taken [published] using ROS using PCL for object recognition? I've read the PCL documentation and it mentions that we need a PCD file [containing the point clouds] for processing. How do we convert the infinite stream of point clouds published by ROS into a PCD file?


Originally posted by PriyankaP on ROS Answers with karma: 53 on 2012-01-30

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

You can convert a ROS PointCloud directly to a PCL datatype so that you can process it using PCL built-in fucntions. See this tutorial.


Originally posted by DimitriProsser with karma: 11163 on 2012-01-30

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

Hi, You can write the pointclouds in the call back function like below. Here

pcl::PointCloud<pcl::PointXYZRGB> PC;    
void callback(const sensor_msgs::PointCloud2::ConstPtr& msg)
    {
        cout<<"Writing the file..."<<endl;
        pcl::fromROSMsg(*msg, PC);
        pcl::io::savePCDFileASCII(path, PC);
        cout<<"Saved "<<PC.points.size()<<" data points "<<path<<endl;

    }

But this will re-write the file at the same rate at which the pointclouds are published in ros. So you may have to exit it manually.

Hope it helps!!

Karthik


You may have to follow the tutorial for including the files and having a start off on this issues. If the package is already created then you have to edit the manifest.xml file to include the dependencies of the pcl_ros as mentioned in the tutorial. Pls, always edit your question for further clarifications, do not post new answers. Let me know any if you are facing any other issues.

Karthik


Originally posted by karthik with karma: 2831 on 2012-01-30

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.