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

Point Clouds in ROS

asked 2012-01-30 04:32:04 -0500

PriyankaP gravatar image

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?

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
2

answered 2012-01-30 05:42:18 -0500

DimitriProsser gravatar image

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.

edit flag offensive delete link more
2

answered 2012-01-30 05:45:17 -0500

karthik gravatar image

updated 2012-01-30 21:16:11 -0500

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

edit flag offensive delete link more
0

answered 2012-01-30 21:03:06 -0500

PriyankaP gravatar image

this is the main function for my reciever program.

int main(int argc, char** argv)

{

ros::init(argc, argv, "sub_pcl");

ros::NodeHandle nh;

ros::Subscriber sub = nh.subscribe<pointcloud>("points2", 1, callback);

ros::spin();

}

The reciever file worked fine. But rosmake gives following errors after including the callback function.

/home/rootx/pcl_proj/src/receiver.cpp:31: error: ‘PointCloud’ was not declared in this scope /home/rootx/pcl_proj/src/receiver.cpp:31: error: no matching function for call to ‘ros::NodeHandle::subscribe(const char [8], int, void (&)(const boost::shared_ptr<co< p="">

Is there some header file I need to include for that particular function?

edit flag offensive delete link more

Comments

edited my answer for this issue
karthik gravatar image karthik  ( 2012-01-30 21:16:44 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2012-01-30 04:32:04 -0500

Seen: 1,748 times

Last updated: Jan 30 '12