2

I have to extract images and PCDs from a rosbag file.
I'm using Python 2 and rosbag library to iterate through messages:

import rosbag
from cv_bridge import CvBridge

bag = rosbag.Bag('test.bag')
bridge = CvBridge()
for topic, msg, t in self.bag.read_messages():
    # if image, use bridge
    # but what what to do to save a PointCloud into a PCD?

Is there some library (like cv_bridge) that can help me with extracting PCD from a rosbag?
I found pypcd, but I don't know if it does what I hope it does, as it doesn't work in Python 2, and I can't make rosbag library work in Python 3...

Any idea?

Lovro
  • 712
  • 1
  • 10
  • 20

2 Answers2

3

pcl_ros has a tool to convert pointclouds from a bag file to PCD's.

rosrun pcl_ros bag_to_pcd <input_file.bag> <topic> <output_directory>
Shrijit Singh
  • 356
  • 1
  • 8
0

Conversion from message to PointCloud can be done like:

pc = PointCloud.from_msg(msg)

Conversion from PointCloud to message can be done like:

msg = pc.to_msg()
Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49