Description

example

rbdry = roadBoundaries(scenario) returns the road boundaries, rbdry, of a driving scenario, scenario.

rbdry = roadBoundaries(ac) returns the road boundaries that the actor, ac, follows in a driving scenario.

Examples

collapse all

Create a driving scenario containing a curved road, two straight roads, and two actors: a car and a bicycle. Both actors move along the road for 60 seconds.

Create the driving scenario object.

scenario = drivingScenario('SampleTime',0.1','StopTime',60);

Create the curved road using road center points following the arc of a circle with an 800-meter radius. The arc starts at 0°, ends at 90°, and is sampled at 5° increments.

angs = [0:5:90]';
R = 800;

roadcenters = [700 0 0; 100 0 0];
barrier(scenario,sr1)
roadcenters = [400 400 0; 0 0 0];

Add a car and a bicycle to the scenario. Position the car at the beginning of the first straight road.

car = vehicle(scenario,'ClassID',1,'Position',[700 0 0], ...
'Length',3,'Width',2,'Height',1.6);

Position the bicycle farther down the road.

bicycle = actor(scenario,'ClassID',3,'Position',[706 376 0]', ...
'Length',2,'Width',0.45,'Height',1.5);

Plot the scenario.

title('Scenario');

Display the actor poses and profiles.

allActorPoses = actorPoses(scenario)
allActorPoses=242×1 struct array with fields:
ActorID
Position
Velocity
Roll
Pitch
Yaw
AngularVelocity

allActorProfiles = actorProfiles(scenario)
allActorProfiles=242×1 struct array with fields:
ActorID
ClassID
Length
Width
Height
OriginOffset
MeshVertices
MeshFaces
RCSPattern
RCSAzimuthAngles
RCSElevationAngles

Because there are barriers in this scenario, and each barrier segment is considered an actor, actorPoses and actorProfiles functions return the poses of all stationary and non-stationary actors. To only obtain the poses and profiles of non-stationary actors such as vehicles and bicycles, first obtain their corresponding actor IDs using the scenario.Actors.ActorID property.

movableActorIDs = [scenario.Actors.ActorID];

Then, use those IDs to filter only non-stationary actor poses and profiles.

movableActorPoseIndices = ismember([allActorPoses.ActorID],movableActorIDs);

movableActorPoses = allActorPoses(movableActorPoseIndices)
movableActorPoses=2×1 struct array with fields:
ActorID
Position
Velocity
Roll
Pitch
Yaw
AngularVelocity

movableActorProfiles = allActorProfiles(movableActorPoseIndices)
movableActorProfiles=2×1 struct array with fields:
ActorID
ClassID
Length
Width
Height
OriginOffset
MeshVertices
MeshFaces
RCSPattern
RCSAzimuthAngles
RCSElevationAngles

Create a driving scenario containing a figure-8 road specified in the world coordinates of the scenario. Convert the world coordinates of the scenario to the coordinate system of the ego vehicle.

Create an empty driving scenario.

scenario = drivingScenario;

20 -20  1
20  20  1
-20 -20  1
-20  20  1
0   0  1];

bankAngle = [0 15 15 -15 -15 0];
plot(scenario)

Add an ego vehicle to the scenario. Position the vehicle at world coordinates (20, –20) and orient it at a –15 degree yaw angle.

ego = actor(scenario,'ClassID',1,'Position',[20 -20 0],'Yaw',-15);

Obtain the road boundaries in ego vehicle coordinates by using the roadBoundaries function. Specify the ego vehicle as the input argument.

Display the result on a bird's-eye plot.

bep = birdsEyePlot;
plotLaneBoundary(lbp,rbEgo1)

Obtain the road boundaries in world coordinates by using the roadBoundaries function. Specify the scenario as the input argument.

Obtain the road boundaries in ego vehicle coordinates by using the driving.scenario.roadBoundariesToEgo function.

Display the road boundaries on a bird's-eye plot.

bep = birdsEyePlot;
plotLaneBoundary(lbp,{rbEgo2})

Input Arguments

collapse all

Driving scenario, specified as a drivingScenario object.

Actor belonging to a drivingScenario object, specified as an Actor or Vehicle object. To create these objects, use the actor and vehicle functions, respectively.

Output Arguments

collapse all

Road boundaries, returned as a cell array. Each cell in the cell array contains a real-valued N-by-3 matrix representing a road boundary in the scenario, where N is the number of road boundaries. Each row of the matrix corresponds to the (x, y, z) coordinates of a road boundary vertex.

When the input argument is a driving scenario, the road coordinates are with respect to the world coordinates of the driving scenario. When the input argument is an actor, the road coordinates are with respect to the actor coordinate system.

The figures show the number of road boundaries that rbdry contains for various road types.