Read point cloud data from ROS or ROS 2 message structure based on field name
pcloud — Point cloud
'sensor_msgs/PointCloud2' message structure
Point cloud, specified as a message structure for ROS or ROS 2
fieldname — Field name of point cloud data
string scalar | character vector
Field name of point cloud data, specified as a string scalar or character
vector. This string must match the field name exactly. If
fieldname does not exist, the function displays an
fielddata — List of field values from point cloud
List of field values from point cloud, returned as a matrix. Each row of the matrix is a point cloud reading, where n is the number of points and c is the number of values for each point.
PreserveStructureOnRead name-value pair argument
is set to
true, the points are returned as an
Point cloud data can be organized in either 1-D lists or in 2-D image styles. 2-D
image styles usually come from depth sensors or stereo cameras. The input
PointCloud2 object contains a
property that is either
Suppose you set the property to
pcloud.PreserveStructureOnRead = true;
Now calling any read functions (
rosReadField) preserves the organizational structure of the point cloud.
When you preserve the structure, the output matrices are of size
m is the height, n is the width, and
d is the number of return values for each point. Otherwise, all
points are returned as a x-by-d list. This
structure can be preserved only if the point cloud is organized.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Usage in MATLAB Function block is not supported.
Introduced in R2021a