Ask Your Question

Create PointCloud2 in Matlab

asked 2018-05-15 12:53:26 -0500

I am looking to create a PointCloud2 message in MATLAB and publish back to ROS via the Robotics Systems Toolbox. I am receiving a PointCloud2 message from my Intel Realsense camera and processing the RGB data for a lane detection algorithm. I am then using the distance data to know how far away the line is and to also integrate into my local Costmap for use in the Navigation Stack.

Is there a quick and dirty way to create this message in MATLAB. There is a function called readRGB and readXYZ within MATLAB to extract a depth image and a color image from the rgbd PointCloud2 but I cannot get that information back into the PointCloud2 message. I am not very familiar with using Point Clouds and would appreciate any help!!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-05-16 05:56:53 -0500

Looking at the Robotics Systems Toolbox, there definitely isn't a quick way although there may be a dirty way!

If the Height, Width, ... , Fields, and Data properties allow writing you could add this data in manually yourself. But this is a very clunky task to achieve in MatLab.

Creating point cloud messages doesn't seem to be a task they wanted you do with this toolbox!

edit flag offensive delete link more


Do you recommend another method for processing a 3D cloud? I have been looking at the Point Cloud Library but have no experience with it.

cmfuhrman gravatar image cmfuhrman  ( 2018-05-16 12:04:50 -0500 )edit

I'm an only school c++ coder so I would naturally recommend PCL, it's very powerful as well as easy to extend with your own algorithms. If you're comfortable working in c++ then you should definitely give it at go.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-05-16 12:21:58 -0500 )edit

They have a fairly good range of examples and theoretical tutorials to get you started, and it's fully integrated with ROS.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-05-16 12:22:55 -0500 )edit

Thank you for your assistance!

cmfuhrman gravatar image cmfuhrman  ( 2018-05-17 11:30:42 -0500 )edit

answered 2019-03-14 14:26:31 -0500

sea-bass gravatar image


I've written a utility that can do this for both MATLAB and Simulink. You can find the files here:


edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools



Asked: 2018-05-15 12:53:26 -0500

Seen: 806 times

Last updated: May 16 '18