Read Point Cloud

Extract point cloud from ROS PointCloud2 message

  • Library:
  • Robotics System Toolbox / ROS

Description

The Read Point Cloud block extracts a point cloud from a ROS PointCloud2 message. You can select the ROS message parameters of a topic active on a live ROS network or specify the message parameters separately. The ROS messages are specified as a nonvirtual bus. Use the Subscribe block to receive a message from a ROS network and input the message to the Read Point Cloud block.

Note

When reading ROS point cloud messages from the network, the Data property of the message can exceed the maximum array length set in Simulink®. To increase the maximum array length, click Tools > Manage Array Lengths > Robot Operating System , select the Data array, and increase the size based on the number of points in the point cloud.

Ports

Input

expand all

ROS PointCloud2 message, specified as a nonvirtual bus. You can use the Subscribe block to get a message from the ROS network.

Data Types: bus

Output

expand all

x, y, and z coordinates of the point cloud data, output as either an N-by-3 matrix or h-by-w-by-3 multidimensional array. N is the number of points. h and w are the height and width of the image in pixels. To get the x, y, and z coordinates as a multidimensional array, select the Preserve point cloud structure check box in the block mask parameters.

Data Types: single

RGB values for each point of the point cloud data, output as either an N-by-3 matrix or h-by-w-by-3 multidimensional array. N is the number of points. h and w are the height and width of the image in pixels. The RGB values correspond to the red, green, and blue color intensities with a range of [0 1].To get the RGB values as a multidimensional array, select the Preserve point cloud structure check box in the block mask parameters.

Data Types: double

Intensity values for each point of the point cloud data, output as either an array or a h-by-w matrix. h and w are the height and width of the image in pixels. To get the intensity values as a matrix, select the Preserve point cloud structure check box in the block mask parameters.

Data Types: single

Error code for image conversion, returned as a scalar. The error code values are:

  • 0 – Successfully converted the point cloud message.

  • 1 – The dimensions of the incoming point cloud exceed the limits set in Maximum point cloud size.

  • 2 – One of the variable-length arrays in the incoming message was truncated. See Managing Array Sizes in Simulink ROS to increase the maximum length of the array.

  • 3 – The X, Y, or Z field of the point cloud message is missing.

  • 4 –The point cloud does not contain any RGB color data. You must have toggled Show RGB output port to on to get this error .

  • 5 –The point cloud does not contain any intensity data. You must have toggled Show Intensity output port to on to get this error.

  • 6 – The X, Y, or Z field of the point cloud message does not have the correct data type (float32).

  • 7 – The RGB field of the point cloud message does not have the correct data type (float32).

  • 8 – The Intensity field of the point cloud message does not have the correct data type (float32).

For certain error codes, data is truncated or populated with NaN values where appropriate.

Data Types: uint8

Parameters

expand all

Maximum point cloud image size, specified as a two-element [height width] vector.

Click Configure using ROS ... to set this parameter automatically using an active topic on a ROS network. You must be connected to the ROS network.

When this check box is selected, the cloud data output shape for XYZ, RGB, and Intensity are preserved. The outputs maintain the structure of the original image. Therefore, XYZ and RGB are output as multidimensional arrays, and Intensity is output as a matrix.

Select this check box to get RGB values for each point of the point cloud message from the RGB port. The RGB data must be supplied by the message.

Select this check box to get intensity values for each point of the point cloud message from the Intensity port. The intensity data must be supplied by the message.

Select this check box to monitor errors with the ErrorCode port.

Select this check box to output variable-size signals. Variable-sized signals should only be used if the image size is expected to change over time. For more information about variable sized signals, see Variable-Size Signal Basics (Simulink).

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Introduced in R2017b