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

31 views (last 30 days)
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 ?

Accepted Answer

Josh Chen
Josh Chen on 1 Mar 2023
Hi Dayananda,
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,
Josh

More Answers (1)

Seshu Vakamudi
Seshu Vakamudi on 28 Oct 2023
Edited: Seshu Vakamudi on 28 Oct 2023
Hi Dayananda,
If you have Lidar Toolbox license and ROS toolbox license, you can load your ros bag into Lidar Viewer app. You can visualize point clouds with its rich set of options. This app helps you with basic analysis and measurement options. You can edit/preprocess the point cloud through this app. The export option in this app helps you to write point clouds into pcd/ply formats.
Feel free to post here if you have any difficulty.
Hope this helps,
Seshu Vakamudi

Categories

Find more on Specialized Messages in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!