addAutomaticManeuvers
R2026bDescription
addAutomaticManeuvers( creates
maneuvers automatically between approach road lanes in a junction by using heuristic lane
mapping to determine appropriate lane connections. RoadRunner preserves existing maneuvers in the junction, allowing you to supplement
manually created maneuvers with additional automatically generated connections.rrJunction)
Examples
Create a roadrunner object,
specifying the path to an existing project. For example, this code shows the path to a
project, on a Windows® machine, located at "C:\RR\MyProject". This code
assumes that RoadRunner is installed in the default location, and returns an object,
rrApp, that provides functions for performing basic tasks such as
opening, closing, and saving scenes and projects.
rrApp = roadrunner(ProjectFolder="C:\RR\MyProject");Note
If you are opening RoadRunner from MATLAB® for the first time, or if you have changed the RoadRunner installation location since you last opened it from MATLAB, you can use the roadrunnerSetup function to specify new default
project and installation folders to use when opening RoadRunner. You can save these folders between MATLAB sessions by selecting the Across MATLAB
sessions option from the corresponding dropdown.
Create a new RoadRunner scene in the current project by using the
newScene function, specifying the roadrunner object
rrApp.
newScene(rrApp);
Create a RoadRunner authoring API object, rrAPI, that references the
object for the current RoadRunner instance rrApp. The rrApi object
enables you to programmatically author scenes, such as by adding and modifying road
and lane components, using MATLAB.
rrApi = roadrunnerAPI(rrApp);
Scene
property of the authoring API object rrApi. The extracted
Scene object enables you to specify the scene in which to add
scene components, such as roads and lanes.
scn = rrApi.Scene
Use the addSegmentedRoad function to add a segmented curve type
road to the scene. Specify the starting point of the road as a control point. Next,
indicate the forward direction of the road by specifying a second control point. You
must specify the positions of these control points along the X- and Y- axes of the
RoadRunner local coordinate
system.
startPoint1 = [0 0]; startRoadDirection1 = [1 0]; rrRoad1 = addSegmentedRoad(scn,startPoint1,startRoadDirection1);
Extract the horizontal curve of the segmented road. Then, use the
addLine function to create a line segment and add it to the
horizontal
curve.
segmentedCurve1 = rrRoad1.HorizontalCurve; addLine(segmentedCurve1,100);
Extract the reference lane of the road from the ReferenceLane
property of the road object rrRoad1. The reference lane defines the
center lane, or reference line, of a road in a RoadRunner scene. This lane has no
width and serves as the basis for positioning all other lanes, which RoadRunner
arranges outward from the reference line.
refLane1 = rrRoad1.ReferenceLane;
Use the extracted refLane1 object to add lane on the left side
of the reference lane of the road using the addLaneToLeft function.
Then, use the LaneType and TravelDirection
properties of the added lane to specify the type and travel direction, respectively.
Add a driving lane to the left of the horizontal road with a backward travel
direction.
horizontalLane1 = addLaneToLeft(refLane1); horizontalLane1.LaneType = "driving"; horizontalLane1.TravelDirection = "backward";
Configure the width profile for the left lane by specifying the
WidthProfile property of the lane. Specify the width of the
lane.
horizontalLane1WidthProfile = horizontalLane1.WidthProfile; startNode1 = horizontalLane1WidthProfile.Nodes(1); startNode1.EndWidth = 3.5; endNode1 = horizontalLane1WidthProfile.Nodes(end); endNode1.StartWidth = 3.5;
Use the extracted refLane1 object to add another lane on the
right side of the reference lane of the road using the
addLaneToRight function. Then, use the
LaneType and TravelDirection properties of the
lane to specify the type and travel direction, respectively. Add a driving lane to the
right of the horizontal road with a forward travel direction.
horizontalLane2 = addLaneToRight(refLane1); horizontalLane2.LaneType = "driving"; horizontalLane2.TravelDirection = "forward";
Configure the width profile for the right lane by specifying the
WidthProfile property of the lane. Specify the width of the
lane.
horizontalLane2WidthProfile = horizontalLane2.WidthProfile; startNode2 = horizontalLane2WidthProfile.Nodes(1); startNode2.EndWidth = 3.5; endNode2 = horizontalLane2WidthProfile.Nodes(end); endNode2.StartWidth = 3.5;
Use the addSegmentedRoad function to add another segmented
curve type road to the scene. Specify the starting point of the road as a control
point. Next, indicate the forward direction of the road by specifying a second control
point. You must specify the positions of these control points along the X- and Y- axes
of the RoadRunner local coordinate system.
startPoint2 = [110 0]; startRoadDirection2 = [1 0]; rrRoad2 = addSegmentedRoad(scn,startPoint2,startRoadDirection2);
Extract the horizontal curve of the second segmented road. Then, use the
addLine function to create a line segment and add it to the
second horizontal curve.
segmentedCurve2 = rrRoad2.HorizontalCurve; addLine(segmentedCurve2,100);
Extract the reference lane of the road from the ReferenceLane
property of the road object rrRoad2.
refLane2 = rrRoad2.ReferenceLane;
Use the extracted refLane2 object to add lane on the left side
of the second reference lane of the road using the addLaneToLeft
function. Then, use the LaneType and
TravelDirection properties of the added lane to specify the type
and travel direction, respectively. Add a driving lane to the left of the second
horizontal road with a backward travel direction.
horizontalLane3 = addLaneToLeft(refLane2); horizontalLane3.LaneType = "driving"; horizontalLane3.TravelDirection = "backward";
Configure the width profile for the second left lane by specifying the
WidthProfile property of the lane. Specify the width of the
lane.
horizontalLane3WidthProfile = horizontalLane3.WidthProfile; startNode3 = horizontalLane3WidthProfile.Nodes(1); startNode3.EndWidth = 3.5; endNode3 = horizontalLane3WidthProfile.Nodes(end); endNode3.StartWidth = 3.5;
Use the extracted refLane2 object to add another lane on the
right side of the reference lane of the road using the
addLaneToRight function. Then, use the
LaneType and TravelDirection properties of the
lane to specify the type and travel direction, respectively. Add a driving lane to the
right of the second horizontal road with a forward travel direction.
horizontalLane4 = addLaneToRight(refLane2); horizontalLane4.LaneType = "driving"; horizontalLane4.TravelDirection = "forward";
Configure the width profile for the second right lane by specifying the
WidthProfile property of the lane. Specify the width of the
lane.
horizontalLane4WidthProfile = horizontalLane4.WidthProfile; startNode4 = horizontalLane4WidthProfile.Nodes(1); startNode4.EndWidth = 3.5; endNode4 = horizontalLane4WidthProfile.Nodes(end); endNode4.StartWidth = 3.5;
Create a junction at distance ranges specified by
startDistances and endDistances. You must
specify these distance ranges as control points along the X- and Y- axes of the
RoadRunner local coordinate system.
roads = [rrRoad1, rrRoad2]; startDistances = [90, -1]; endDistances = [-1, 10]; rrJunction = addJunction(scn, roads, startDistances, endDistances);
Create automatic maneuvers on the junction using the
addAutomaticManeuvers function. Then, extract the
Maneuver object from the Maneuvers property of
the Junction object to view the maneuvers.
addAutomaticManeuvers(rrJunction) rrManeuvers = rrJunction.Maneuvers
Input Arguments
Junction to add maneuvers to, specified as a Junction object.
Version History
Introduced in R2026b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)