Main Content

pointCloudPlotter

Point cloud plotter for bird's-eye plot

Since R2020a

Description

example

pcPlotter = pointCloudPlotter(bep) creates a point cloud plotter object that configures the display of lidar point cloud data on a bird's-eye plot. The point cloud plotter object is stored in the Plotters property of the input bird's-eye plot object, bep. To plot the lidar point cloud data, use the plotPointCloud function.

pcPlotter = pointCloudPlotter(bep,Name,Value) specifies options using one or more name-value pair arguments. For example, 'DisplayName','Point Cloud' sets the display name that appears in the bird's-eye-plot legend to "Point Cloud".

Examples

collapse all

Generate lidar point cloud data for a driving scenario with multiple actors by using the lidarPointCloudGenerator System object. Create the driving scenario by using drivingScenario object. It contains an ego-vehicle, pedestrian and two other vehicles.

Create and plot a driving scenario with multiple vehicles

Create a driving scenario.

scenario = drivingScenario;

Add a straight road to the driving scenario. The road has one lane in each direction.

roadCenters = [0 0 0; 70 0 0];
laneSpecification = lanespec([1 1]);
road(scenario,roadCenters,'Lanes',laneSpecification);

Add an ego vehicle to the driving scenario.

egoVehicle = vehicle(scenario,'ClassID',1,'Mesh',driving.scenario.carMesh);
waypoints = [1 -2 0; 35 -2 0];
smoothTrajectory(egoVehicle,waypoints,10);

Add a truck, pedestrian, and bicycle to the driving scenario and plot the scenario.

truck = vehicle(scenario,'ClassID',2,'Length', 8.2,'Width',2.5,'Height',3.5, ...
    'Mesh',driving.scenario.truckMesh);
waypoints = [70 1.7 0; 20 1.9 0];
smoothTrajectory(truck,waypoints,15);

pedestrian = actor(scenario,'ClassID',4,'Length',0.24,'Width',0.45,'Height',1.7, ...
    'Mesh',driving.scenario.pedestrianMesh);
waypoints = [23 -4 0; 10.4 -4 0];
smoothTrajectory(pedestrian,waypoints,1.5);

bicycle = actor(scenario,'ClassID',3,'Length',1.7,'Width',0.45,'Height',1.7, ...
    'Mesh',driving.scenario.bicycleMesh);
waypoints = [12.7 -3.3 0; 49.3 -3.3 0];
smoothTrajectory(bicycle,waypoints,5);

plot(scenario,'Meshes','on')

Generate and plot lidar point cloud data

Create a lidarPointCloudGenerator System object.

lidar = lidarPointCloudGenerator;

Add actor profiles and the ego vehicle actor ID from the driving scenario to the System object.

lidar.ActorProfiles = actorProfiles(scenario);
lidar.EgoVehicleActorID = egoVehicle.ActorID;

Plot the point cloud data.

bep = birdsEyePlot('Xlimits',[0 70],'YLimits',[-30 30]);
plotter = pointCloudPlotter(bep);
legend('off');
while advance(scenario)
    tgts = targetPoses(egoVehicle);
    rdmesh = roadMesh(egoVehicle);
    [ptCloud,isValidTime] = lidar(tgts,rdmesh,scenario.SimulationTime);
    if isValidTime
        plotPointCloud(plotter,ptCloud);
    end
end

Input Arguments

collapse all

Bird’s-eye plot, specified as a birdsEyePlot object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'DisplayName','Point Cloud' sets the display name that appears in the bird's-eye-plot legend to "Point Cloud".

Plotter name to display in legend, specified as the comma-separated pair consisting of 'DisplayName' and character vector or string scalar. If you do not specify a name, the bird's-eye plot does not display a legend entry for the plotter.

Data Types: char | string

Size of marker for points in a point cloud, specified as the comma-separated pair consisting of 'PointSize' and a positive integer in points.

Point fill color, specified as the comma-separated pair consisting of 'Color' and an RGB triplet, a hexadecimal color code, a color name, or a short color name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7].

  • A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Therefore, the color codes "#FF8800", "#ff8800", "#F80", and "#f80" are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan" "c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

Tag associated with the plotter object, specified as the comma-separated pair consisting of 'Tag' and a character vector or string scalar. The default value is 'PlotterN', where N is an integer that corresponds to the Nth plotter associated with the input birdsEyePlot object.

Output Arguments

collapse all

Point cloud plotter, returned as a pointCloudPlotter object. You can modify this object by changing its property values.

pcPlotter is stored in the Plotters property of the input, bep. To plot the point cloud data, use the plotPointCloud function.

Version History

Introduced in R2020a