Add a barrier to a driving scenario
adds a barrier along a piecewise, clothoid curve that smoothly connects the specified
barrier centers. This approach is useful when adding barriers to edges of roads that
intersect or overlap.
specifies the angle by which the barrier tilts when traversing the barrier centers.
sets barrier properties using one or more name-value pair arguments, in addition to any
combination of input arguments from previous syntaxes.
Barriers are composed of individual elements called barrier
segments. Use name-value pair arguments such as
'Height' to tune the properties of individual barrier segments.
Jersey barriers and guardrails are the two types of barriers that you can add to a scenario.
Specify the appropriate
arguments to represent the barrier as a guardrail or a jersey barrier.
Add Barriers Along Road Edges in Driving Scenario
Create a driving scenario and add a curved road.
scenario = drivingScenario; roadCenters = [-14.1 -4.3; 9 -10; 37 -8; 60 3.9; 81.2 29.4; 83.4 57.9]; road1 = road(scenario,roadCenters);
Add a barrier along the right edge of the road.
Add another barrier along the left edge of the road with a lateral offset of 1 m from the edge. Specify a gap of 1 m between individual barrier segments.
Plot the scenario.
Add Barriers to Driving Scenario at Specific Points
Create a driving scenario and add a straight road.
scenario2 = drivingScenario; roadCenters = [0 0; 20 0]; rr = road(scenario2,roadCenters);
Specify appropriate barrier centers and add a barrier on the road, covering the entire width of the road.
barrierCenters = [20 3; 20 0; 20 -3]; barrier(scenario2,barrierCenters,'SegmentGap',0.2)
Add two barriers on the road, each covering half the width of the road.
barrierCenters1 = [12 3; 12 0]; barrierCenters2 = [6 -3; 6 0]; barrier(scenario2,barrierCenters1,'SegmentGap',0.2) barrier(scenario2,barrierCenters2,'SegmentGap',0.2)
Plot the scenario.
scenario — Driving scenario
Driving scenario, specified as a
rd — Road to add a barrier along
Road to add a barrier along, specified as a
barrierCenters — Barrier center coordinates
N-by-3 matrix | real-valued
Barrier center coordinates, specified as an N-by-3 or N-by-2 matrix.
barrierCentersis an N-by-3 matrix, then each matrix row represents the (x, y, z) coordinates of a barrier center.
barrierCentersis an N-by-2 matrix, then each matrix row represents the (x, y) coordinates of a barrier center. The z-coordinate of each barrier center is zero.
The function connects the coordinates along a smooth, piecewise, clothoid curve, and adds a barrier with the curve as its center line. Units are in meters.
bankAngle — Banking angle of barrier
0 (default) | scalar | real-valued
Banking angle of barrier, specified as a real-valued N-by-1 vector. N is the number of barrier centers. The bankAngle is the roll angle of the barrier along the direction of the curve formed by the barrier centers. Units are in degrees.
Specify optional pairs of arguments as
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.
'RoadEdge','left' adds a barrier along the left edge of the
RoadEdge — Edge of road along which to place a barrier
'right' (default) |
Edge of the road along which to place a barrier, specified as the comma-separated
pair consisting of
'RoadEdge' only when you specify
road object to add a barrier along.
RoadEdgeOffset — Lateral offset from road edge
scalar | real-valued
Lateral offset from road edge, specified as the comma-separated pair consisting of
'RoadEdgeOffset' and a scalar or real-valued
N-by-1 vector. N is the number of
barrier centers. A positive offset value moves the barrier away from the road and a
negative offset value moves the barrier into the road. Units are in meters.
'RoadEdgeOffset' is valid only when you specify a
road object and
SegmentLength — Length of each barrier segment
5 (default) | positive real scalar
Length of each barrier segment, specified as the comma-separated pair consisting
'SegmentLength' and a positive real scalar. Units are in meters.
SegmentGap — Distance between consecutive barrier segments
0 (default) | positive real scalar
Distance between consecutive barrier segments, specified as the comma-separated
pair consisting of
'SegmentGap' and a positive real scalar. Units
are in meters.
Width — Width of each barrier segment
0.5 (default) | positive real scalar
Width of each barrier segment, specified as the comma-separated pair consisting of
'Width' and a positive real scalar. Units are in meters.
Height — Height of each barrier segment
0.75 (default) | positive real scalar
Height of each barrier segment, specified as the comma-separated pair consisting
'Height' and a positive real scalar. Units are in meters.
Mesh — Mesh representation of barrier
Mesh representation of the barrier, specified as the comma-separated pair
'Mesh' and a valid
extendedObjectMesh object. The available meshes for barrier are
driving.scenario.jerseyBarrierMesh, representing a Jersey barrier and
driving.scenario.guardrailMesh, representing a guardrail. The
lidarPointCloudGenerator system object uses this mesh to generate
PlotColor — Display color of barrier
[0.6 0.6 0.6] (default) | RGB triplet | hexadecimal color code | color name | short color name
Display color of barrier, specified as the comma-separated pair consisting of
'PlotColor' and an RGB triplet, hexadecimal color code, color
name, or short color name.
The barrier appears in the specified color in all programmatic scenario
visualizations, including the
chasePlot function, and plotting functions of
birdsEyePlot objects. If you import the scenario into the Driving Scenario
Designer app, then the barrier appears in this color in all app
visualizations. If you import the scenario into Simulink®, then the barrier appears in this color in the Bird's-Eye
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
F. The values are not case sensitive. Therefore, the color codes
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 Name||Short Name||RGB Triplet||Hexadecimal Color Code||Appearance|
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.
|RGB Triplet||Hexadecimal Color Code||Appearance|
RCSPattern — Radar cross-section pattern of barrier
[10 10; 10 10] (default) | Q-by-P real-valued matrix
Radar cross-section (RCS) pattern of the barrier, specified as the comma-separated
pair consisting of
'RCSPattern' and a
Q-by-P real-valued matrix. The RCS is a
function of the azimuth and elevation angles, where:
Q is the number of elevation angles specified by the
'RCSElevationAngles'name-value pair argument.
P is the number of azimuth angles specified by the
'RCSAzimuthAngles'name-value pair argument.
Units are in decibels per square meter (dBsm).
RCSAzimuthAngles — Azimuth angles of RCS pattern of barrier
[-180 180] (default) | P-element real-valued vector
Azimuth angles of RCS pattern of barrier, specified as the comma-separated pair
'RCSAzimuthAngles' and a P-element
real-valued vector. P is the number of azimuth angles. Values are
in the range [–180°, 180°].
Each element of
'RCSAzimuthAngles' defines the azimuth angle
of the corresponding column of the
'RCSPattern' name-value pair
argument. Units are in degrees.
RCSElevationAngles — Elevation angles of RCS pattern of barrier
[-90 90] (default) | Q-element real-valued vector
Elevation angles of RCS pattern of barrier, specified as the comma-separated pair
'RCSElevationAngles' and a
Q-element real-valued vector. Q is the number of
elevation angles. Values are in the range [–90°, 90°].
Each element of
'RCSElevationAngles' defines the elevation
angle of the corresponding row of the
pair argument. Units are in degrees.
ClassID — Classification identifier
0 (default) |
Classification identifier of the barrier, specified as the comma-separated pair
'ClassID' and a nonnegative integer value of
6. The values
6 correspond to Jersey barriers and guardrails, respectively.
Specify the appropriate Class ID for each barrier before importing the scenario into
the Driving Scenario
Designer app. For more information about the Class ID values for different
actors, refer to the description of the
'ClassID' name-value pair argument.
Road networks added using the
roadNetworkfunction do not support barriers.
For faster simulations, specify the input argument
targetPosesfunction in the scenario advance loop.
Introduced in R2021a