setRadius
R2026bDescription
sets the corner radius fillet to the specified radius and recomputes the corner geometry. A
corner radius fillet is the curved corner that connects adjacent road segments. The corner
radius determines the size of the curve and defines the shape of the corner road and the
path the vehicle takes while making a turn. When you specify a new radius, RoadRunner recalculates the curved corner geometry after applying the specified
radius.isSet = setRadius(rrCorners,radius)
Examples
Create a junction with four roads and modify the corner radius for the junction created.
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);
Extract the object for your scene from the
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 42]; startRoadDirection1 = [0 -1]; 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,35);
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 = [0 -42]; startRoadDirection2 = [0 1]; 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,35);
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;
Use the addSegmentedRoad function to add a third 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.
startPoint3 = [42 0]; startRoadDirection3 = [-1 0]; rrRoad3 = addSegmentedRoad(scn,startPoint3,startRoadDirection3);
Extract the horizontal curve of the third segmented road. Then, use the
addLine function to create a line segment and add it to the third
horizontal curve.
segmentedCurve3 = rrRoad3.HorizontalCurve; addLine(segmentedCurve3,35);
Extract the reference lane of the road from the ReferenceLane
property of the road object rrRoad3.
refLane3 = rrRoad3.ReferenceLane;
Use the extracted refLane3 object to add lane on the left side of
the reference lane of the third 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 third
horizontal road with a backward travel direction.
horizontalLane5 = addLaneToLeft(refLane3); horizontalLane5.LaneType = "driving"; horizontalLane5.TravelDirection = "backward";
Configure the width profile for the third left lane by specifying the
WidthProfile property of the lane. Specify the width of the
lane.
horizontalLane5WidthProfile = horizontalLane5.WidthProfile; startNode5 = horizontalLane5WidthProfile.Nodes(1); startNode5.EndWidth = 3.5; endNode5 = horizontalLane5WidthProfile.Nodes(end); endNode5.StartWidth = 3.5;
Use the extracted refLane3 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 third horizontal
road with a forward travel direction.
horizontalLane6 = addLaneToRight(refLane3); horizontalLane6.LaneType = "driving"; horizontalLane6.TravelDirection = "forward";
Configure the width profile for the third right lane by specifying the
WidthProfile property of the lane. Specify the width of the
lane.
horizontalLane6WidthProfile = horizontalLane6.WidthProfile; startNode6 = horizontalLane6WidthProfile.Nodes(1); startNode6.EndWidth = 3.5; endNode6 = horizontalLane6WidthProfile.Nodes(end); endNode6.StartWidth = 3.5;
Use the addSegmentedRoad function to add a fourth 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.
startPoint4 = [-42 0]; startRoadDirection4 = [1 0]; rrRoad4 = addSegmentedRoad(scn,startPoint4,startRoadDirection4);
Extract the horizontal curve of the fourth segmented road. Then, use the
addLine function to create a line segment and add it to the fourth
horizontal curve.
segmentedCurve4 = rrRoad4.HorizontalCurve; addLine(segmentedCurve4,35);
Extract the reference lane of the road from the ReferenceLane
property of the road object rrRoad4.
refLane4 = rrRoad4.ReferenceLane;
Use the extracted refLane4 object to add lane on the left side of
the reference lane of the forth 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 fourth
horizontal road with a backward travel direction.
horizontalLane7 = addLaneToLeft(refLane4); horizontalLane7.LaneType = "driving"; horizontalLane7.TravelDirection = "backward";
Configure the width profile for the fourth left lane by specifying the
WidthProfile property of the lane. Specify the width of the
lane.
horizontalLane7WidthProfile = horizontalLane7.WidthProfile; startNode7 = horizontalLane7WidthProfile.Nodes(1); startNode7.EndWidth = 3.5; endNode7 = horizontalLane7WidthProfile.Nodes(end); endNode7.StartWidth = 3.5;
Use the extracted refLane4 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 fourth horizontal
road with a forward travel direction.
horizontalLane8 = addLaneToRight(refLane4); horizontalLane8.LaneType = "driving"; horizontalLane8.TravelDirection = "forward";
Configure the width profile for the fourth right lane by specifying the
WidthProfile property of the lane. Specify the width of the
lane.
horizontalLane8WidthProfile = horizontalLane8.WidthProfile; startNode8 = horizontalLane8WidthProfile.Nodes(1); startNode8.EndWidth = 3.5; endNode8 = horizontalLane8WidthProfile.Nodes(end); endNode8.StartWidth = 3.5;
Create a junction at distance ranges specified by startDistances
and endDistances. This creates a junction at a distance of
30m inside each the roads.
roads = [rrRoad1, rrRoad2, rrRoad3, rrRoad4]; startDistances = [30, 30, 30, 30]; endDistances = [-1, -1, -1, -1]; rrJunction = addJunction(scn, roads, startDistances, endDistances);
Retrieve the corner roads of the junction by extracting the
Corner object from the Corners property of the
Junction object.
rrCorners = rrJunction.Corners
Modify the radius of each corner of the junction using the
setRadius function and specifying the new radius for all
corners.
for i = 1:numel(rrCorners) setRadius(rrCorners(i), 10.0) end
Input Arguments
Corner whose radius is to be modified, specified as Corner object.
Radius of the corner, specified as a positive scalar. Units are in meters.
Data Types: double
Error when the radius is not applied, specified as true or 1 or
false or 0. When set to true, it throws an
error specifying that a valid corner cannot be constructed using the specified radius.
When set to false, it uses a smaller default fallback radius to
construct a corner.
Data Types: bool
Output Arguments
Status of radius application, specified as a logical. It returns
true if setRadius applies the radius and
false otherwise.
Version History
Introduced in R2026b
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)