Main Content

RoadGroup

Store specifications for road junction or intersection

Since R2021a

Description

The RoadGroup object stores the specifications of road segments that combine to form a road junction or intersection.

Creation

To create a RoadGroup object, use the driving.scenario.RoadGroup creation function. Then, create a road junction or intersection by following these steps:

  1. Define the road segments and add them to the RoadGroup object by using the road function.

  2. Combine the road segments to form a junction or intersection and add it to a driving scenario by using the roadGroup function.

Description

rg = driving.scenario.RoadGroup creates a RoadGroup object with properties Name and Roads.

example

rg = driving.scenario.RoadGroup('Name',name) additionally specifies the name, name for the road junction, where name is a character vector or string scalar. name sets the Name property.

Properties

expand all

This property is read-only.

Name of the road junction or intersection, stored as a string scalar. The name argument sets this property value.

Example: driving.scenario.RoadGroup('Name','junction1') creates a RoadGroup object with a Name property of "junction1".

Data Types: string

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 road function:

FieldValue
Width

A positive real scalar specifying the width of the road. Units are in meters.

LanesA lanespec object specifying the properties of lanes in the road.
Name

A string scalar specifying the name of the road.

Centers

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.

BankAngle

An N-element vector of real values specifying the banking values for the road. N is the number of centers in the road.

Data Types: struct

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);

Version History

Introduced in R2021a

See Also

Objects

Functions