Display point cloud in scatter plot
pcloud point cloud as a 3-D scatter
plot in the current axes handle. If the data contains RGB information
for each point, the scatter plot is colored accordingly.
scatter3( provides additional
options specified by one or more
Name,Value pair arguments. Name
must appear inside single quotes
(''). You can specify several
name-value pair arguments in any order as
the scatter series object, using any of the arguments from previous
h = scatter3(___)
h to modify properties of the scatter
series after it is created.
When plotting ROS point cloud messages, MATLAB® follows the standard ROS convention for axis orientation. This convention states that positive x is forward, positive y is left, and positive z is up. If cameras are used, a second frame is defined with an “_optical” suffix that changes the orientation of the axis. In this case, positive z is forward, positive x is right, and positive y is down. MATLAB looks for the “_optical” suffix and will adjust the axis orientation of the scatter plot accordingly. For more information, see Axis Orientation on the ROS Wiki.
Connect to a ROS network. Subscribe to a point cloud message topic.
Initializing global node /matlab_global_node_65972 with NodeURI http://192.168.17.1:51971/
sub = rossubscriber('/camera/depth/points'); pause(1)
Get the latest point cloud message. Plot the point cloud.
pcloud = sub.LatestMessage; scatter3(pcloud)
Plot all points as black dots.
scatter3(sub.LatestMessage,'MarkerEdgeColor',[0 0 0]);
pcloud— Point cloud
Point cloud, specified as a
handle for a
'sensor_msgs/PointCloud2' ROS message.
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'MarkerEdgeColor',[1 0 0]
'Parent'— Parent of axes
Parent of axes, specified as the comma-separated pair consisting of
'Parent' and an axes object in which to draw the
point cloud. By default, the point cloud is plotted in the active
h— Scatter series object
Scatter series object, returned as a scalar. This value is a unique identifier, which you can use to query and modify the properties of the scatter object after it is created.