Main Content


Lane marking plotter for bird's-eye plot



lmPlotter = laneMarkingPlotter(bep) creates a LaneMarkingPlotter object that configures the display of lane markings on a bird's-eye plot. The LaneMarkingPlotter object is stored in the Plotters property of the input birdsEyePlot object, bep. To display the lane markings, use the plotLaneMarking function.

lmPlotter = laneMarkingPlotter(bep,Name,Value) sets properties using one or more Name,Value pair arguments. For example, laneMarkingPlotter(bep,'DisplayName','Lane markings') sets the display name that appears in the bird's-eye-plot legend.


collapse all

Create a driving scenario containing an ego vehicle and a target vehicle traveling along a three-lane road. Detect the lane boundaries by using a vision detection generator.

scenario = drivingScenario;

Create a three-lane road by using lane specifications.

roadCenters = [0 0 0; 60 0 0; 120 30 0];
lspc = lanespec(3);

Specify that the ego vehicle follows the center lane at 30 m/s.

egovehicle = vehicle(scenario,'ClassID',1);
egopath = [1.5 0 0; 60 0 0; 111 25 0];
egospeed = 30;

Specify that the target vehicle travels ahead of the ego vehicle at 40 m/s and changes lanes close to the ego vehicle.

targetcar = vehicle(scenario,'ClassID',1);
targetpath = [8 2; 60 -3.2; 120 33];
targetspeed = 40;

Display a chase plot for a 3-D view of the scenario from behind the ego vehicle.


Create a vision detection generator that detects lanes and objects. The pitch of the sensor points one degree downward.

visionSensor = visionDetectionGenerator('Pitch',1.0);
visionSensor.DetectorOutput = 'Lanes and objects';
visionSensor.ActorProfiles = actorProfiles(scenario);

Run the simulation.

  1. Create a bird's-eye plot and the associated plotters.

  2. Display the sensor coverage area.

  3. Display the lane markings.

  4. Obtain ground truth poses of targets on the road.

  5. Obtain ideal lane boundary points up to 60 m ahead.

  6. Generate detections from the ideal target poses and lane boundaries.

  7. Display the outline of the target.

  8. Display object detections when the object detection is valid.

  9. Display the lane boundary when the lane detection is valid.

bep = birdsEyePlot('XLim',[0 60],'YLim',[-35 35]);
caPlotter = coverageAreaPlotter(bep,'DisplayName','Coverage area', ...
detPlotter = detectionPlotter(bep,'DisplayName','Object detections');
lmPlotter = laneMarkingPlotter(bep,'DisplayName','Lane markings');
lbPlotter = laneBoundaryPlotter(bep,'DisplayName', ...
    'Lane boundary detections','Color','red');
olPlotter = outlinePlotter(bep);
    visionSensor.MaxRange,visionSensor.Yaw, ...
while advance(scenario)
    [lmv,lmf] = laneMarkingVertices(egovehicle);
    tgtpose = targetPoses(egovehicle);
    lookaheadDistance = 0:0.5:60;
    lb = laneBoundaries(egovehicle,'XDistance',lookaheadDistance,'LocationType','inner');
    [obdets,nobdets,obValid,lb_dets,nlb_dets,lbValid] = ...
    [objposition,objyaw,objlength,objwidth,objoriginOffset,color] = targetOutlines(egovehicle);
    plotOutline(olPlotter,objposition,objyaw,objlength,objwidth, ...
    if obValid
        detPos = cellfun(@(d)d.Measurement(1:2),obdets,'UniformOutput',false);
        detPos = vertcat(zeros(0,2),cell2mat(detPos')');
    if lbValid

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: laneBoundaryPlotter('Color','red') sets the color of lane markings to red.

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.

Face color of lane marking patches, specified as the comma-separated pair consisting of 'FaceColor' and an RGB triplet or one of the color names listed in the table.

For a custom color, specify an RGB triplet. 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]. Alternatively, you can specify some common colors by name. This table lists the named color options and the equivalent RGB triplet values.

Color NameRGB TripletAppearance
'red'[1 0 0]

Sample of the color red

'green'[0 1 0]

Sample of the color green

'blue'[0 0 1]

Sample of the color blue

'cyan' [0 1 1]

Sample of the color cyan

'magenta'[1 0 1]

Sample of the color magenta

'yellow'[1 1 0]

Sample of the color yellow

'black'[0 0 0]

Sample of the color black

'white'[1 1 1]

Sample of the color white

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

Lane marking plotter, returned as a LaneMarkingPlotter object. You can modify this object by changing its property values. The property names correspond to the name-value pair arguments of the laneMarkingPlotter function.

lmPlotter is stored in the Plotters property of the input birdsEyePlot object, bep. To plot the lane markings, use the plotLaneMarking function.

Version History

Introduced in R2018a