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

Revision history [back]

click to hide/show revision 1
initial version

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

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

Hi, You can write the pointclouds in the call back function like below.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

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