Main Content

roadGroup

Add road junction or intersection to driving scenario

Since R2021a

Description

example

roadGroup(scenario,rg) creates a road junction or intersection from road segments and adds it to the driving scenario scenario. The RoadGroup object rg specifies the road segments that link the roads meeting at an intersection.

Examples

collapse all

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.

yintersection.png

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.

figure
plot(scenario)

Create Y-Junction to Connect Roads

Create a 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.

roadGroup(scenario,rg);

Input Arguments

collapse all

Driving scenario, specified as a drivingScenario object.

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 RoadGroup object.

Note

  • You cannot alter the properties of road segments after adding them to the RoadGroup object.

Limitations

  • The function does not support lane markings in intersections.

  • The scenario plot does not display the road centers in the intersection.

Tips

  • Add at least one road segment to the RoadGroup object to create an intersection using the roadGroup function.

  • 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 RoadGroup object 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 RoadGroup object.

Version History

Introduced in R2021a