Add road junction or intersection to driving scenario
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.
scenario — Driving scenario
Driving scenario, specified as a
rg — Specifications for road segments
Specifications for road segments that form an intersection, specified as a
RoadGroup object. Add separate road segments to connect each pair of
incoming roads meeting at an intersection. Use the
road function to add a road segment to the
You cannot alter the properties of road segments after adding them to the
The function does not support lane markings in intersections.
The scenario plot does not display the road centers in the intersection.
Add at least one road segment to the
RoadGroupobject to create an intersection using the
To create a smooth surface shape in an intersection, you must match the specifications (road centers, width, elevation and banking angle) of the road segments in the
RoadGroupobject to those of the incoming roads meeting at the intersection.
The function considers only the first lane specification for each road segment while creating an intersection, so specify only a single lane specification for each road segment of the
Introduced in R2021a