R.W. swami - 2023-06-06T14:01:58+00:00
Question: how to convert .bag file into .pcd in matlab (Lidar Data) ?
I'm using L515 Lidar for data collection, I'm getting data .bag format from Realsense Viewer . I need to convert to .pcd format, How can I achieve that using Matlab ?
Expert Answer
John Williams answered .
2025-11-20
To achieve this with MATLAB, you would need both ROS Toolbox license and Computer Vision Toolbox license. You can check whether you have these with:
>> ver
If you have both licenses, you can follow these steps and examples to read from .bag format, convert to point cloud, and save to .pcd format:
- Read .bag files with rosbagreader, this example shows how to read specific message from the .bag file. You would need to select the topic that correspond to the sensor_msgs/PointCloud2 message in .bag file.
- Use rosReadXYZ (and rosReadRGB if you also want the color of the point cloud) from each of those ROS messages.
- Use pointCloud to create pointCloud objects in MATLAB.
- Save those pointCloud objects to .pcd filie with pcwrite.
Hope this helps,
Not satisfied with the answer ?? ASK NOW