ROS Custom Message cannot use readXYZ

조회 수: 2 (최근 30일)
FJB427
FJB427 2020년 4월 20일
답변: Cam Salzberger 2020년 4월 22일
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