Importing ROS bag file of LIDAR scan into Matlab as point cloud structure
14 次查看(过去 30 天)
显示 更早的评论
how to derive point cloud data structure for matlab with points, x y z limit and intensity from ROS bag file.
I need point cloud data in this form for postprocessing in Matlab:
I have ROS bag file imported in Matlab in this form:
I have ROS topics and messages in the bag file with the points. I want to know how to get the point cloud data needed for implementing all the algortihms in Matlab. I could not get much help online. Thank you.
0 个评论
采纳的回答
Cam Salzberger
2020-11-24
So you have the XYZ points from the PointCloud2 message after you use readXYZ, and you want to get it in the format of the pointCloud object? That's simple enough, you can just call pointCloud with the XYZ points as input.
If there is color data in the ROS message, you can get that out using readRGB and then provide that to the pointCloud constructor:
xyz = readXYZ(ptCloudMsgs{1});
rgb = readRGB(ptCloudMsgs{1});
ptCloudObj = ptCloud(xyz, "Color", rgb);
-Cam
3 个评论
Cam Salzberger
2020-11-30
I'm a bit confused about what you are asking. If you are asking why, when you use readXYZ on a single scan, there are multiple sets of (x, y, z) coordinates in that, then the answer is because that is what a lidar scan is. It contains multiple points, because the lidar is used to sense range readings on multiple points in the area. If you want just a single point of data, then you probably want to use a laser rangefinder or similar sensor that just takes the distance to a single point.
If you are asking why you have multiple lidar scans, that is (I'm assuming) because you are reading multiple messages out of the rosbag at one time. If you only want to read one message out of the rosbag at a time, you can provide a "rows" argument to readMessages. However, I'd recommend that you continue to read all messages out at once (as long as it fits in your computer's RAM), and then loop through them to process them individually.
-Cam
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specialized Messages 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!