perception_pcl icon indicating copy to clipboard operation
perception_pcl copied to clipboard

Save point cloud topic XYZRGBA per timestamp does not work

Open brunoeducsantos opened this issue 6 years ago • 1 comments

Hi, My goal is to to save per timestamp pcd files from a pointcloud XYZRGB topic using the following command:

rosrun pcl_ros pointcloud_to_pcd input:=/segmenter/seg_cloud

Using this command I only got one single file which is override every timestamp and has the following values:

# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 178
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 178
DATA ascii
-4.3638158 -4.9323435 -1.2216021 -2.9909723e+38
-3.8820915 -4.9016023 -1.2167848 -2.9909723e+38
-4.1596241 -4.6367893 -1.2122004 -2.9909723e+38
-3.8411894 -4.637763 -1.2335668 -2.9909723e+38
-3.9321952 -4.545362 -1.2311586 -2.9909723e+38
-4.1745772 -4.4535785 -1.2504237 -2.9909723e+38
-3.6174207 -4.328846 -1.2069463 -2.9909723e+38
-3.522413 -4.3764153 -1.2019252 -2.9909723e+38

The way I am publishing the point cloud is:

 pcl::PointCloud<pcl::PointXYZRGB> cloud_xyzrgb;          
          copyPointCloud(view.point_cloud, cloud_xyzrgb);
          int r= rand() % 255;
          int g= rand() % 255;
          int b = rand() % 255;
          std::transform(cloud_xyzrgb.points.begin(), cloud_xyzrgb.points.end(), cloud_xyzrgb.points.begin(), [r,g,b](pcl::PointXYZRGB p) { p.r = r;p.g =g; p.b= b; return p;});
          cloud_xyzrgb.header.frame_id = "base_link";
          seg_publisher_.publish(cloud_xyzrgb);

Properties:

  • PCL 1.8
  • ROS kinetic Ubuntu 16.04

Does anyone has the same issue? Thanks, Bruno

brunoeducsantos avatar Apr 30 '19 13:04 brunoeducsantos

So your problem is that the file is overwritten, do I understand that correctly? What is the name of the file? I don't see that you set the stamp of the header of cloud_xyzrgb anywhere, so if that is always the same, that would be the reason why it gets overwritten (because the time stamp is the name). Also: you should not save PointXYZRGB as ASCII. Either switch to PointXYZRGBA or save as binary. See here (under Caution).

mvieth avatar Nov 12 '19 20:11 mvieth