how to convert .bag file into .pcd in matlab (Lidar Data) ?

Illustration
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

Profile picture of John Williams 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:
  1. 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.
  2. Use rosReadXYZ (and rosReadRGB if you also want the color of the point cloud) from each of those ROS messages.
  3. Use pointCloud to create pointCloud objects in MATLAB.
  4. Save those pointCloud objects to .pcd filie with pcwrite.
Hope this helps,


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!