Missing Ros Message while Running pointcloud to pcd
Hi,
Can anyone please tell me why I am getting less pcd file compared to the number of my point cloud message in my rosbag while running the
"rosrun pclros pointcloudto_pcd input:=/velodyne/pointcloud2" command
In other case when I am running the bag to pcd command using the "rosrun pclros bagtopcd data.bag /lasertilt_cloud ./pointclouds" command. I am getting the exact number of pcd files comparing to my point cloud message in my Ros bag.
Any guide will be very helpful.
Thanks
Asked by Dina on 2019-08-27 15:47:28 UTC
Answers
After taking a look at the source code my guess is because the pointcloud_to_pcd
has a queue of 1. This means that if it is processing some message n
, it is perhaps that by the time the callback is finished running n+1
is no longer the most recent message and thus is ignored.
sub_ = nh_.subscribe (cloud_topic_, 1, &PointCloudToPCD::cloud_cb, this);
Whereas bag_to_pcd
will just iteratively inspect the messages in the bag.
Asked by PapaG on 2019-08-27 23:54:46 UTC
Comments
@PapaG thank you, I faced the same problem and increasing the queue size solved the problem. Now I am able to save all cloud msgs into pcd.
Asked by Mathanraj_Sharma on 2021-01-09 14:35:39 UTC
@PapaG is not wrong, but I feel that answer misses an important point: the fact that bag_to_pcd
uses a fundamentally different way of processing the .bag
file.
Pub-sub is typically implemented such that it makes no guarantees about whether you receive a message (there are implementations that do, but ROS 1's is not one of those).
bag_to_pcd
does not use pub-sub, it iterates over the messages in the .bag
file directly (using the rosbag
API, examples here). That is implemented as a blocking operation, and that is why no messages are "lost": there is simply no way to advance to the next message before the current one has been processed.
Asked by gvdhoorn on 2019-08-28 02:27:53 UTC
Comments
Kind of feel like you just expanded the final sentence of my answer into something irrelevant to the actual question being asked...
Asked by PapaG on 2019-08-28 07:00:56 UTC
I disagree. OP specifically asked:
Can anyone please tell me why I am getting less pcd file compared to the number of my point cloud message in my rosbag while running the
"rosrun pcl_ros pointcloud_to_pcd input:=/velodyne/pointcloud2" command
In other case when I am running the bag to pcd command using the "rosrun pcl_ros bag_to_pcd data.bag /laser_tilt_cloud ./pointclouds" command.
Unless I misunderstood this, this asks for the reason why the nr of msgs is different between bag_to_pcd
and pointcloud_to_pcd
.
The queue size in pointcloud_to_pcd
is almost irrelevant, as even with a queue of a 1000 (or some other large nr), it would still not be possible to guarantee that all messages in a .bag
would be processed.
The fundamental difference is the use of pub-sub vs loading the .bag
directly.
Asked by gvdhoorn on 2019-08-28 07:10:30 UTC
Comments