selectActorRoads
R2026bSyntax
Description
Add-On Required: This feature requires the Scenario Builder for Automated Driving Toolbox add-on.
extracts properties of roads in the path of an actor,
actorRoadProperties = selectActorRoads(roadProperties,waypoints)actorRoadProperties, from the input road properties
roadProperties, which contains road information for a road network.
waypoints specifies the position of the actor at each
waypoint.
specifies options using name-value arguments in addition to the input arguments from the
previous syntax. For example, actorRoadProperties = selectActorRoads(___,Name=Value)MaxDistance=2 specifies the maximum
distance from a waypoint to a road boundary as 2 meters.
Examples
Specify geographic coordinates to create waypoints for an actor.
lat = linspace(42.300742,42.301988,50); lon = linspace(-71.352551,-71.345491,50); alt = zeros(1,50);
Use latitude and longitude to fetch the map parameters for the corresponding region.
mapParameters = getMapROI(lat,lon);
Use the osmUrl parameter in the mapParameters output structure to import and save the OpenStreetMap file.
filename = websave("drive_map.osm",mapParameters.osmUrl, ... weboptions(ContentType="xml"));
Get the road network properties from the map.
[roadProperties,geoReference] = roadprops("OpenStreetMap",filename);Convert the geographic coordinates to local Cartesian coordinates, and create waypoints.
[xEast,yNorth,zUp] = latlon2local(lat,lon,alt,geoReference); waypoints = [xEast; yNorth; zUp]';
Extract and display the actor road properties.
actorRoadProperties = selectActorRoads(roadProperties,waypoints)
actorRoadProperties = 18×10 table
3 0 "Wheeler Lane" 14×3 double 7.3500 14×1 double 14×1 double 1×1 lanespec 132×3 double 132×3 double
11 0 "Worcester Street" 44×3 double 3.7500 41×1 double 41×1 double 1×1 lanespec 860×3 double 860×3 double
24 0 "567740618" 18×3 double 7.3500 18×1 double 18×1 double 1×1 lanespec 181×3 double 181×3 double
25 0 "567740619" 5×3 double 3.7500 [0;0;0;0;0] [NaN;NaN;NaN;NaN;NaN] 1×1 lanespec 20×3 double 20×3 double
26 0 "567740619" 5×3 double 3.7500 [0;0;0;0;0] [NaN;NaN;NaN;NaN;NaN] 1×1 lanespec 20×3 double 20×3 double
28 0 "567741165" [249.1556,43.7474,-0.0050;242.1030,113.6270,-0.0056] 7.3500 [0;0] [NaN;NaN] 1×1 lanespec 37×3 double 37×3 double
29 0 "567741168" 51×3 double 7.3500 [0;0;0;0;0;0;0;0;0;0] [NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN] 1×1 lanespec 66×3 double 66×3 double
30 0 "567741168" 13×3 double 7.3500 13×1 double 13×1 double 1×1 lanespec 78×3 double 78×3 double
34 0 "567741798" 19×3 double 7.3500 19×1 double 19×1 double 1×1 lanespec 74×3 double 74×3 double
35 0 "567741799" 4×3 double 7.3500 [0;0;0;0] [NaN;NaN;NaN;NaN] 1×1 lanespec 11×3 double 11×3 double
36 0 "567741799" 7×3 double 7.3500 [0;0;0;0;0;0;0] [NaN;NaN;NaN;NaN;NaN;NaN;NaN] 1×1 lanespec 24×3 double 24×3 double
37 0 "567741799" [-65.0187,-0.7773,-0.0003;-63.7737,-20.6271,-0.0004;-63.3450,-27.5362,-0.0004] 7.3500 [0;0;0] [NaN;NaN;NaN] 1×1 lanespec 15×3 double 15×3 double
39 0 "567741801" [-82.5250,-30.3574,-0.0006;-84.2236,-23.6260,-0.0006;-88.7916,-5.5090,-0.0006] 7.3500 [0;0;0] [NaN;NaN;NaN] 1×1 lanespec 14×3 double 14×3 double
41 0 "567741801" [-126.0630,-10.3626,-0.0013;-124.3647,-29.5348,-0.0013;-123.7546,-36.4218,-0.0013] 7.3500 [0;0;0] [NaN;NaN;NaN] 1×1 lanespec 15×3 double 15×3 double
⋮
Specify geographic coordinates to create waypoints for an actor.
lat = linspace(42.300742,42.301688,50); lon = linspace(-71.352551,-71.345491,50); alt = zeros(1,50);
Use latitude and longitude to fetch the map parameters for the corresponding region.
mapParameters = getMapROI(lat,lon);
Use the osmUrl parameter in the mapParameters output structure to import and save the OpenStreetMap file.
filename = websave("drive_map.osm",mapParameters.osmUrl, ... weboptions(ContentType="xml"));
Get the road network properties from the map.
[roadProperties,geoReference] = roadprops("OpenStreetMap",filename);Convert the geographic coordinates to local Cartesian coordinates, and create waypoints.
[xEast,yNorth,zUp] = latlon2local(lat,lon,alt,geoReference); waypoints = [xEast; yNorth; zUp]';
Extract and display the actor road properties.
actorRoadProperties = selectActorRoads(roadProperties,waypoints, ... RoadNames="Worcester Street")
actorRoadProperties = 4×10 table
7 0 "Worcester Street" 44×3 double 3.7500 41×1 double 41×1 double 1×1 lanespec 860×3 double 860×3 double
8 0 "Worcester Street" [-230.5812,-33.1755,-0.0042;14.8261,4.6542,-0.0000] 3.7500 [0;0] [NaN;NaN] 1×1 lanespec 126×3 double 126×3 double
9 0 "Worcester Street" [14.8261,4.6542,-0.0000;256.8089,39.8044,-0.0053] 3.7500 [0;0] [NaN;NaN] 1×1 lanespec 124×3 double 124×3 double
10 0 "Worcester Street" 30×3 double 3.7500 34×1 double 34×1 double 1×1 lanespec 522×3 double 522×3 double
Input Arguments
Road properties of a road network, specified as a table. The table must contain these columns.
| Column | Description |
|---|---|
RoadID | Identifier of road, specified as a positive integer. |
JunctionID | Identifier of junction, specified as a positive integer. |
RoadName | Name of road, specified as a character vector. |
RoadCenters | Road centers used to define a road, specified as a real-valued N-by-3 matrix, where N is the number of road centers. |
RoadWidth | Width of road in meters, specified as a positive real scalar. |
LeftBoundary | Left boundaries of the road segment, specified as an M-by-3 matrix. M is the number of road boundary points. |
RightBoundary | Right boundaries of the road segment, specified as an M-by-3 matrix. M is the number of road boundary points. |
Actor positions in the navigation coordinate system, in meters, specified as a P-by-3 matrix. P is the number of waypoints. Each waypoint represents the position of the actor in the form [x y z].
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: selectActorRoads(roadProperties,waypoints,MaxDistance=2)
specifies the maximum distance from a waypoint to a road boundary as 2
meters.
Maximum Euclidean distance from a waypoint to a road boundary, in meters,
specified as a nonnegative scalar. Roads with boundaries at a distance greater than
MaxDistance from each waypoint are excluded in the returned
actorRoadProperties table.
Data Types: single | double
Name of the roads in the path of an actor, specified as a character vector, string scalar, string array, or cell array of character vectors.
By default, the function returns the properties of all the roads in the path of
the actor. If you specify this argument, the function extracts only the roads in the
path of the actor that are specified in RoadNames.
To use this name-value argument, you must know the names of the roads beforehand.
Note
Road names are generally present only for road networks extracted using an OpenStreetMap® road network file.
Data Types: string | char | cell
Output Arguments
Actor road properties, returned as a table. The table contains the properties of the
roads near the specified actor waypoints. This table has the same columns as the
roadProperties table.
Version History
Introduced in R2022b
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)