addLaneToLeft
Description
creates a lane, rrLeftLane
= addLaneToLeft(rrLane
)rrLeftLane
, to the left side of the specified lane or
reference lane, rrLane
, relative to the road direction.
Examples
This example shows how to create a RoadRunner scene with single horizontal road and add two driving lanes with opposite travel directions.
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 drop down.
Create a new RoadRunner scene in the current project by using the newScene
function, specifying the roadrunner object rrApp
.
newScene(rrApp);
Create an object for the RoadRunner authoring API, 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 lanes 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 elements such as roads and lanes.
scn = rrApi.Scene;
Add 100 meters long horizontal line-arc curve road to the scene by using the addLineArcRoad
function. Specify the position of the road by specifying the positions of its control points along the X- and Y- axes of the RoadRunner local coordinate system. These control points define the position of the start and end of the road. You can modify the position of the control points to adjust the length and direction of the road relative to the scene origin. You can also add additional control points in between the start and end points of the line-arc curve to adjust curvature and radius of the road curve.
controlPoints = [-50 0; 50 0]; rrHorizontalRoad = addLineArcRoad(scn,controlPoints);
Extract the reference lane of the road from the ReferenceLane
property of the road object rrHorizontalRoad
. 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 are arranged outward from the reference line.
refLane = rrHorizontalRoad.ReferenceLane;
Use the extracted refLane
object to add lanes on either side of the reference lane of the road using the addLaneToLeft
and addLaneToRight
functions. Then, use the LaneType
and TravelDirection
properties of the added lanes to specify the type of lane and the travel direction of each lane. Add a driving lane to the left of the horizontal road with forward travel direction.
horizontalLane1 = addLaneToLeft(refLane); horizontalLane1.LaneType = "Driving"; horizontalLane1.TravelDirection = "Forward";
Add another driving lane to the right of the horizontal road with backward travel direction.
horizontalLane2 = addLaneToRight(refLane); horizontalLane2.LaneType = "Driving"; horizontalLane2.TravelDirection = "Backward";
This figure shows the scene in the RoadRunner scene canvas.
Input Arguments
Lane or reference lane to which to add a new lane to the left side, relative to the
road direction, specified as a Lane
object or ReferenceLane
object.
Output Arguments
New lane added to the left side of the specified lane or reference lane, relative to
road direction, returned as a Lane
object.
Version History
Introduced in R2025a
See Also
roadrunnerAPI
| roadrunnerSetup
| Scene
| Lane
(RoadRunner) | addLineArcRoad
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)