Store specifications for road junction or intersection
RoadGroup object stores the specifications of road segments
that combine to form a road junction or intersection.
To create a
RoadGroup object, use the
driving.scenario.RoadGroup creation function. Then, create a road
junction or intersection by following these steps:
rg = driving.scenario.RoadGroup
RoadGroup object with properties
additionally specifies the name,
rg = driving.scenario.RoadGroup('Name',
name for the road junction, where
name is a character vector or string scalar.
name sets the
Name — Name of road junction or intersection
' ' (default) | string scalar
This property is read-only.
Name of the road junction or intersection, stored as a string scalar. The
name argument sets this property value.
driving.scenario.RoadGroup('Name','junction1') creates a
RoadGroup object with a
Name property of
Roads — Specifications of road segments
cell array of structures
This property is read-only.
Specifications of road segments in the road group, stored as a cell array of
structures. Each structure contains these fields, and their values are set by the
A positive real scalar specifying the width of the road. Units are in meters.
A string scalar specifying the name of the road.
An N-by-2 or N-by-3 matrix of real values specifying the centers in the road. N is the number of centers in the road.
An N-element vector of real values specifying the banking values for the road. N is the number of centers in the road.
Create Road Network with Three-Way Intersection
A three-way intersection is a Y-Junction in which two adjacent roads intersect the third road at an obtuse angle, as shown in this figure. To connect the three roads, you will create a Y-Junction by adding three road segments.
Add Three Roads to Driving Scenario
Create an empty driving scenario.
scenario = drivingScenario;
Specify the number of lanes and the width of each lane in the roads.
ls = lanespec(2,'Width',5);
Define the road centers for three roads and add them to the driving scenario. The first road is diagonally oriented to the left of the scenario canvas, second road is diagonally oriented to the right of the scenario canvas, and the third road is oriented vertically.
% Add the first road roadCenters = [-20 0; 6 0]; road(scenario,roadCenters,'Name','Road 1','Lanes',ls); % Add the second road roadCenters = [23 7; 50 33]; road(scenario,roadCenters,'Name','Road 2','Lanes',ls); % Add the third road roadCenters = [23 -7; 50 -33]; road(scenario,roadCenters,'Name','Road 3','Lanes',ls);
Plot the scenario.
Create Y-Junction to Connect Roads
RoadGroup object. Specify the width for each road segment that forms the Y-junction.
rg = driving.scenario.RoadGroup('Name','Y-Junction'); roadWidth = 10;
Specify the road centers for three road segments, and add these road segments to the
RoadGroup object by using the
road function. These road segments intersect with each other.
% Add the first road segment roadCenters = [23 7; 14 1; 6 0]; road(rg,roadCenters,roadWidth,'Name','Segment 1'); % Add the second road segment roadCenters = [23 -7; 14 -1; 6 0]; road(rg,roadCenters,roadWidth,'Name','Segment 2'); % Add the third road segment roadCenters = [23 7; 21 4; 21 -4; 23 -7]; road(rg,roadCenters,roadWidth,'Name','Segment 3');
Add Y-Junction to Driving Scenario
Add the road segments stored in the
RoadGroup object to the driving scenario by using the
roadGroup function. The road segments form a Y-Junction that connects the three roads in the driving scenario.
Introduced in R2021a