selectActorRoads
Syntax
Description
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.
Note
This function requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install Scenario Builder for Automated Driving Toolbox from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.
Examples
Extract Actor Road Segments Using Waypoints
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
RoadID JunctionID RoadName RoadCenters RoadWidth BankAngle Heading Lanes LeftBoundary RightBoundary
______ __________ __________________ _____________ _________ _____________ _____________ ____________ ______________ ______________
3 0 "Wheeler Lane" {14×3 double} 7.35 {14×1 double} {14×1 double} 1×1 lanespec {132×3 double} {132×3 double}
11 0 "Worcester Street" {44×3 double} 3.75 {41×1 double} {41×1 double} 1×1 lanespec {860×3 double} {860×3 double}
24 0 "567740618" {18×3 double} 7.35 {18×1 double} {18×1 double} 1×1 lanespec {181×3 double} {181×3 double}
25 0 "567740619" { 5×3 double} 3.75 { 5×1 double} { 5×1 double} 1×1 lanespec { 20×3 double} { 20×3 double}
26 0 "567740619" { 5×3 double} 3.75 { 5×1 double} { 5×1 double} 1×1 lanespec { 20×3 double} { 20×3 double}
28 0 "567741165" { 2×3 double} 7.35 { 2×1 double} { 2×1 double} 1×1 lanespec { 37×3 double} { 37×3 double}
29 0 "567741168" {51×3 double} 7.35 {10×1 double} {10×1 double} 1×1 lanespec { 66×3 double} { 66×3 double}
30 0 "567741168" {13×3 double} 7.35 {13×1 double} {13×1 double} 1×1 lanespec { 78×3 double} { 78×3 double}
34 0 "567741798" {19×3 double} 7.35 {19×1 double} {19×1 double} 1×1 lanespec { 74×3 double} { 74×3 double}
35 0 "567741799" { 4×3 double} 7.35 { 4×1 double} { 4×1 double} 1×1 lanespec { 11×3 double} { 11×3 double}
36 0 "567741799" { 7×3 double} 7.35 { 7×1 double} { 7×1 double} 1×1 lanespec { 24×3 double} { 24×3 double}
37 0 "567741799" { 3×3 double} 7.35 { 3×1 double} { 3×1 double} 1×1 lanespec { 15×3 double} { 15×3 double}
39 0 "567741801" { 3×3 double} 7.35 { 3×1 double} { 3×1 double} 1×1 lanespec { 14×3 double} { 14×3 double}
41 0 "567741801" { 3×3 double} 7.35 { 3×1 double} { 3×1 double} 1×1 lanespec { 15×3 double} { 15×3 double}
55 0 "Worcester Street" { 2×3 double} 3.75 { 2×1 double} { 2×1 double} 1×1 lanespec { 22×3 double} { 22×3 double}
56 0 "Worcester Street" { 3×3 double} 3.75 { 3×1 double} { 3×1 double} 1×1 lanespec { 9×3 double} { 9×3 double}
⋮
Extract Road-Name-Specific Actor Road Properties
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
RoadID JunctionID RoadName RoadCenters RoadWidth BankAngle Heading Lanes LeftBoundary RightBoundary
______ __________ __________________ _____________ _________ _____________ _____________ ____________ ______________ ______________
7 0 "Worcester Street" {44×3 double} 3.75 {41×1 double} {41×1 double} 1×1 lanespec {860×3 double} {860×3 double}
8 0 "Worcester Street" { 2×3 double} 3.75 { 2×1 double} { 2×1 double} 1×1 lanespec {126×3 double} {126×3 double}
9 0 "Worcester Street" { 2×3 double} 3.75 { 2×1 double} { 2×1 double} 1×1 lanespec {124×3 double} {124×3 double}
10 0 "Worcester Street" {30×3 double} 3.75 {34×1 double} {34×1 double} 1×1 lanespec {522×3 double} {522×3 double}
Input Arguments
roadProperties
— Road properties
table
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. |
waypoints
— Actor positions in navigation coordinate system
P-by-3 matrix
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.
MaxDistance
— Maximum Euclidean distance from waypoint to road boundary
5
(default) | nonnegative scalar
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
RoadNames
— Name of roads in path of actor
character vector | string scalar | string array | cell array of character vectors
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
actorRoadProperties
— Actor road properties
table
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)