laneBoundaries
Get lane boundaries of actor lane
Description
specifies options using one or more name-value pairs. For example,
lbdry
= laneBoundaries(ac
,Name,Value
)laneBoundaries(ac,'AllLaneBoundaries',true)
returns all lane
boundaries of the road on which the ego vehicle actor is traveling.
Examples
Simulate Car Traveling on S-Curve
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]; smoothTrajectory(car,waypoints);
Plot the scenario and corresponding chase plot.
plot(scenario)
chasePlot(car)
Run the simulation loop.
Initialize a bird's-eye plot and create an outline plotter, left-lane and right-lane boundary plotters, and a road boundary plotter.
Obtain the road boundaries and rectangular outlines.
Obtain the lane boundaries to the left and right of the vehicle.
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
ac
— Actor
Actor
object | Vehicle
object
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 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: 'LocationType','center'
specifies that lane boundaries
are centered on the lane markings.
XDistance
— Distances from ego vehicle at which to compute lane boundaries
0
(default) | N-element real-valued vector
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.
LocationType
— Lane boundary location
'Center'
(default) | 'Inner'
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 Location | Description | Example |
---|---|---|
'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. |
AllBoundaries
— Return all lane boundaries on road
false
(default) | true
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
lbdry
— Lane boundaries
array of lane boundary structures
Lane boundaries, returned as an array of lane boundary structures. This table shows the fields for each structure.
Field | Description |
| 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.
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. |
| 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. |
| 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. |
| 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. |
| Lateral offset of the ego vehicle position from the lane boundary, 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. In this image, the ego vehicle is offset 1.5 meters from the left lane and 2.1 meters from the right lane. |
| Type of lane boundary marking, specified as one of these values:
|
| Saturation strength of the lane boundary marking, specified as a real scalar from 0 to
1. A value of |
| 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 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. |
| 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. |
Version History
Introduced in R2018a
See Also
Objects
Functions
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)