Ask Your Question
0

bag_to_pcd saves to same file

asked 2019-09-20 07:16:08 -0600

Rasmus2134 gravatar image

Using rosbag, I have recorded the data from a Livox mid-40 lidar. I have played it back and confirmed that the data is there. Now I'd like to convert it to pcd files. I run the command:

rosrun pcl_ros bag_to_pcd data.bag /livox/lidar ./pointclouds

The command runs and I get the output:

Got 5000 data points in frame livox_frame with the following fields: x y z intensity Data saved to ./pointclouds/0.000000000.pcd

Got 5000 data points in frame livox_frame with the following fields: x y z intensity Data saved to ./pointclouds/0.000000000.pcd

...

So it seems that it keeps overwriting the same file when converting instead of making a new file for every message. Thus I only have the last message converted as a pcd file. Has anyone else run into a similar problem?

I'm using melodic at Ubuntu 18.04.

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-09-20 07:40:54 -0600

Looking at the source code for the bag_to_pcd node, the file names are constructed using the timestamp of the point-clouds in the bag file. It's possible that the Livox mid-40 lidar driver you're using isn't adding the timestamp to the topic, which would result in the same file 0.000000000.pcd1 being overwritten repeatedly.

You should be able to check if this is the case by playing back the back file and echoing the lidar point-cloud topic which data disabled using the command below:

rostopic echo /livox/lidar --noarr

If you see the timestamps are always zero then you've confirmed this is the problem. If so the first thing to check is if there is a way to get the driver to start publishing this information. If not you'll have to either add artificial timestamps yourself, or modify the bag_to_pcd node.

edit flag offensive delete link more

Comments

You are correct. The timestamps are always zero for the topic. This might be a silly question, but when playing back the bag file I can see that there are timestamps for the whole file (Bag time). Is it possible to either transfer these to the topic or to use those as the filenames when converting to pcd, such that I wouldn't have to redo the recordings?

Rasmus2134 gravatar imageRasmus2134 ( 2019-09-20 07:51:33 -0600 )edit

It is definitely possible, but this may require making a small modification to the pcl_ros package if you're comfortable doing that. You could modify the source file I linked to earlier and add a condition at line 178 which tests for a zero timestamp in the point cloud and copies the time from the bag file into the cloud in this case. Let me know if you want a few more pointers about how to go about this.

Unfortunately I don't know of a way to do this without modifying code.

PeteBlackerThe3rd gravatar imagePeteBlackerThe3rd ( 2019-09-23 05:04:10 -0600 )edit
1

Thank you very much for the help. I've looked into the Livox driver. There is another driver made by Livox, which does add the timestamp. So problem solved. If there's any other problems with this new driver, I will start modifying the source code.

Rasmus2134 gravatar imageRasmus2134 ( 2019-09-23 06:15:48 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-09-20 07:14:01 -0600

Seen: 43 times

Last updated: Sep 20