ROS Custom Message cannot use readXYZ

2 次查看(过去 30 天)
I have a custom message received via MATLAB, and the would like to use readXYZ on the data. However, since the class of these custom messages are not the dictated 'rosbotics.ros.msg.sensor_msgs.PointCloud2' the function call to readXYZ is not successful. I would think there must be a way to either change the custom message prefix to align with the dictated class or would it be easier to convert to the appropriate class? Any help would be appreciated!

采纳的回答

Cam Salzberger
Cam Salzberger 2020-4-22
Francis,
Currently "readXYZ" is a method only on the PointCloud2 message class. The way that it converts the data from the PointCloud2 "data" array into human-usable (x, y, z) coordinates is specific to the PointCloud2 message format and self-description. It would not work even for sensor_msgs/PointCloud, much less an arbitrary encoding that theoretically contains point cloud data.
If your custom message contains point cloud data in the same format as PointCloud2, then my first question would be, "why not just use the built-in PointCloud2 message?" If you are adding additional information to the message, you could easily create a custom message with a field that contains a PointCloud2 message. If you did that, the PointCloud2 message could be used directly with readXYZ or other similar functions in MATLAB.
If you must use the custom message, but it does contain its data in the same format as PointCloud2, you could simply create a PointCloud2 message object and copy the data into it before calling readXYZ.
If your custom message uses a different way of encoding the point cloud data, though, you will need to write your own method for extracting the data into a usable format.
-Cam

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specialized Messages 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by