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

How to write PCD file from topic without loss data?

asked 2012-06-10 22:03:29 -0500

sam gravatar image

updated 2014-01-28 17:12:37 -0500

ngrennan gravatar image

I use RGBDSLAM to build the room model and sent topic by menu's 'Graph->Send Model'.

It send model to /rgbdslam/batch_clouds.

I write a receiver to receive that topic ,save it to PCD file, and use pcd_viewer to check.

It shows:

image description

The above is RGBDSLAM's model.

The below is viewer by opening pcd file .

I turn it by moving cursor and it seems loss many data.

My receiver code is:

  #include <ros/ros.h>
  #include "std_msgs/String.h"

  #include <pcl/io/pcd_io.h>
  #include <pcl/point_types.h>


  void pcd_receive_Callback(const sen      sor_msgs::PointCloud2::ConstPtr& msg)
  {
          pcl::PointCloud<pcl::PointXYZRGB> cloud;
          pcl::fromROSMsg(*msg, cloud);
          pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);      
  }


  int  main (int argc, char** argv)
  {

          ros::init(argc, argv, "pcd_write_topic");
          ros::NodeHandle n;

          ros::Subscriber sub = n.subscribe("/rgbdslam/batch_clouds", 1000, pcd_receive_Callback);
          ros::spin();


          return (0);
  }

How to solve it?

Thank you~

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2012-06-12 06:01:56 -0500

Are you aware that you can save pcd files directly from rgbdslam? Maybe the clouds are sent to fast for your machine and some are dropped. You can throttle the rate at which the clouds are sent by rgbdslam with a parameter. In your launch file set

<param name="config/send_clouds_rate"              value="2"/>

This will send the clouds out at 2 Hz.

edit flag offensive delete link more

Comments

How to save to pcd file from rgbdslam directly? Thank you~

sam gravatar image sam  ( 2012-06-12 13:39:01 -0500 )edit

In the GUI: Graph->Save as... or Graph->Save Node-Wise. See the Status bar for a description.

Felix Endres gravatar image Felix Endres  ( 2012-06-12 22:22:16 -0500 )edit
0

answered 2012-06-11 06:24:39 -0500

allenh1 gravatar image

Give this a try:

pcl::PCDWriter writer;
writer.write<pcl::PointXYZRGB> ("test_pcd.pcd", cloud, false);
edit flag offensive delete link more

Comments

1

I found that this way is the same with my way. Another thing is I found that my program write pcd file many times. How to many part of point cloud in one pcd file? Or merge many pcd file into one pcd file? Thank you~

sam gravatar image sam  ( 2012-06-13 21:51:09 -0500 )edit

Question Tools

Stats

Asked: 2012-06-10 22:03:29 -0500

Seen: 2,293 times

Last updated: Jan 21 '14