laneBoundaries

Get lane boundaries of actor lane

Description

lbdry = laneBoundaries(ac) returns the lane boundaries, lbdry, of the lane in which the ego vehicle actor, ac, is traveling. The lane boundaries are in the coordinate system of the ego vehicle.

example

lbdry = laneBoundaries(ac,Name,Value) specifies options using one or more name-value pairs. For example, laneBoundaries(ac,'AllLaneBoundaries',true) returns all lane boundaries of the road on which the ego vehicle actor is traveling.

Examples

collapse all

Simulate a driving scenario with one car traveling on an S-curve. Create and plot the lane boundaries.

Create the driving scenario with one road having an S-curve.

scenario = drivingScenario('StopTime',3);
roadcenters = [-35 20 0; -20 -20 0; 0 0 0; 20 20 0; 35 -20 0];

Create the lanes and add them to the road.

lm = [laneMarking('Solid','Color','w'); ...
    laneMarking('Dashed','Color','y'); ...
    laneMarking('Dashed','Color','y'); ...
    laneMarking('Solid','Color','w')];
ls = lanespec(3,'Marking',lm);
road(scenario,roadcenters,'Lanes',ls);

Add an ego vehicle and specify its trajectory from its waypoints. By default, the car travels at a speed of 30 meters per second.

car = vehicle(scenario, ...
    'ClassID',1, ...
    'Position',[-35 20 0]);
waypoints = [-35 20 0; -20 -20 0; 0 0 0; 20 20 0; 35 -20 0];
trajectory(car,waypoints);

Plot the scenario and corresponding chase plot.

plot(scenario)

chasePlot(car)

Run the simulation loop.

  1. Initialize a bird's-eye plot and create an outline plotter, left-lane and right-lane boundary plotters, and a road boundary plotter.

  2. Obtain the road boundaries and rectangular outlines.

  3. Obtain the lane boundaries to the left and right of the vehicle.

  4. Advance the simulation and update the plotters.

bep = birdsEyePlot('XLim',[-40 40],'YLim',[-30 30]);
olPlotter = outlinePlotter(bep);
lblPlotter = laneBoundaryPlotter(bep,'Color','r','LineStyle','-');
lbrPlotter = laneBoundaryPlotter(bep,'Color','g','LineStyle','-');
rbsEdgePlotter = laneBoundaryPlotter(bep);
legend('off');
while advance(scenario)
    rbs = roadBoundaries(car);
    [position,yaw,length,width,originOffset,color] = targetOutlines(car);
    lb = laneBoundaries(car,'XDistance',0:5:30,'LocationType','Center', ...
        'AllBoundaries',false);
    plotLaneBoundary(rbsEdgePlotter,rbs)
    plotLaneBoundary(lblPlotter,{lb(1).Coordinates})
    plotLaneBoundary(lbrPlotter,{lb(2).Coordinates})
    plotOutline(olPlotter,position,yaw,length,width, ...
        'OriginOffset',originOffset,'Color',color)
end

Input Arguments

collapse all

Actor belonging to a drivingScenario object, specified as an Actor or Vehicle object. To create these objects, use the actor and vehicle functions, respectively.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is 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 Name1,Value1,...,NameN,ValueN.

Example: 'LocationType','center' specifies that lane boundaries are centered on the lane markings.

Distances from the ego vehicle at which to compute the lane boundaries, specified as the comma-separated pair consisting of 'XDistance' and an N-element real-valued vector. N is the number of distance values. When detecting lanes from rear-facing cameras, specify negative distances. When detecting lanes from front-facing cameras, specify positive distances. Units are in meters.

By default, the function computes the lane boundaries at a distance of 0 from the ego vehicle, which are the boundaries to the left and right of the ego-vehicle origin.

Example: 1:0.1:10 computes a lane boundary every 0.1 meters over the range from 1 to 10 meters ahead of the ego vehicle.

Example: linspace(-150,150,101) computes 101 lane boundaries over the range from 150 meters behind the ego vehicle to 150 meters ahead of the ego vehicle. These distances are linearly spaced 3 meters apart.

Lane boundary location on the lane markings, specified as the comma-separated pair consisting of 'LocationType' and one of the options in this table.

Lane Boundary LocationDescriptionExample
'Center'Lane boundaries are centered on the lane markings.

A three-lane road has four lane boundaries: one per lane marking.

'Inner'Lane boundaries are placed at the inner edges of the lane markings.

A three-lane road has six lane boundaries: two per lane.

Return all lane boundaries on which the ego vehicle is traveling, specified as the comma-separated pair consisting of 'Value' and false or true.

Lane boundaries are returned from left to right relative to the ego vehicle. When 'AllBoundaries' is false, only the lane boundaries to the left and right of the ego vehicle are returned.

Output Arguments

collapse all

Lane boundaries, returned as an array of lane boundary structures. This table shows the fields for each structure.

FieldDescription

Coordinates

Lane boundary coordinates, specified as a real-valued N-by-3 matrix, where N is the number of lane boundary coordinates. Lane boundary coordinates define the position of points on the boundary at specified longitudinal distances away from the ego vehicle, along the center of the road.

  • In MATLAB®, specify these distances by using the 'XDistance' name-value pair argument of the laneBoundaries function.

  • In Simulink®, specify these distances by using the Distances from ego vehicle for computing boundaries (m) parameter of the Scenario Reader block or the Distance from parent for computing lane boundaries parameter of the Simulation 3D Vision Detection Generator block.

This matrix also includes the boundary coordinates at zero distance from the ego vehicle. These coordinates are to the left and right of the ego-vehicle origin, which is located under the center of the rear axle. Units are in meters.

Curvature

Lane boundary curvature at each row of the Coordinates matrix, specified as a real-valued N-by-1 vector. N is the number of lane boundary coordinates. Units are in radians per meter.

CurvatureDerivative

Derivative of lane boundary curvature at each row of the Coordinates matrix, specified as a real-valued N-by-1 vector. N is the number of lane boundary coordinates. Units are in radians per square meter.

HeadingAngle

Initial lane boundary heading angle, specified as a real scalar. The heading angle of the lane boundary is relative to the ego vehicle heading. Units are in degrees.

LateralOffset

Distance of the lane boundary from the ego vehicle position, specified as a real scalar. An offset to a lane boundary to the left of the ego vehicle is positive. An offset to the right of the ego vehicle is negative. Units are in meters.

BoundaryType

Type of lane boundary marking, specified as one of these values:

  • 'Unmarked' — No physical lane marker exists

  • 'Solid' — Single unbroken line

  • 'Dashed' — Single line of dashed lane markers

  • 'DoubleSolid' — Two unbroken lines

  • 'DoubleDashed' — Two dashed lines

  • 'SolidDashed' — Solid line on the left and a dashed line on the right

  • 'DashedSolid' — Dashed line on the left and a solid line on the right

Strength

Saturation strength of the lane boundary marking, specified as a real scalar from 0 to 1. A value of 0 corresponds to a marking whose color is fully unsaturated. The marking is gray. A value of 1 corresponds to a marking whose color is fully saturated.

Width

Lane boundary width, specified as a positive real scalar. In a double-line lane marker, the same width is used for both lines and for the space between lines. Units are in meters.

Length

Length of dash in dashed lines, specified as a positive real scalar. In a double-line lane marker, the same length is used for both lines.

Space

Length of space between dashes in dashed lines, specified as a positive real scalar. In a dashed double-line lane marker, the same space is used for both lines.

Introduced in R2018a