How to write PCD file from topic without loss data?
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:
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~