Main Content

plot

Plot driving scenario

Description

example

plot(scenario)creates a 3-D plot with orthonormal perspective, as seen from immediately above the driving scenario,scenario.

example

plot(scenario,Name,Value)specifies options using one or more name-value pairs. For example, you can use these options to display road centers and actor waypoints on the plot.

Examples

collapse all

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;

Add a figure-8 road to the scenario. Display the scenario.

roadCenters = [0 0 1 20 -20 1 20 20 1 -20 -20 1 -20 20 1 0 0 1]; roadWidth = 3; bankAngle = [0 15 15 -15 -15 0]; road(scenario,roadCenters,roadWidth,bankAngle); plot(scenario)

Figure contains an axes object. The axes object contains 4 objects of type patch, line.

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);

Figure contains an axes object. The axes object contains 5 objects of type patch, line.

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

rbEgo1 = roadBoundaries(ego);

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

bep = birdsEyePlot; lbp = laneBoundaryPlotter(bep,'DisplayName','Road'); plotLaneBoundary(lbp,rbEgo1)

Figure contains an axes object. The axes object contains an object of type line. This object represents Road.

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

rbScenario = roadBoundaries(scenario);

Obtain the road boundaries in ego vehicle coordinates by using thedriving.scenario.roadBoundariesToEgofunction.

rbEgo2 = driving.scenario.roadBoundariesToEgo(rbScenario,ego);

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

bep = birdsEyePlot; lbp = laneBoundaryPlotter(bep,'DisplayName','Road boundaries'); plotLaneBoundary(lbp,{rbEgo2})

Figure contains an axes object. The axes object contains an object of type line. This object represents Road boundaries.

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 = R*[cosd(angs) sind(angs) zeros(size(angs))]; roadwidth = 10; road(scenario,roadcenters,roadwidth);

Add two straight roads with the default width, using road center points at each end.

roadcenters = [700 0 0; 100 0 0]; road(scenario,roadcenters)
ans = Road with properties: Name: "" RoadID: 2 RoadCenters: [2x3 double] RoadWidth: 6 BankAngle: [2x1 double] Heading: [2x1 double]
roadcenters = [400 400 0; 0 0 0]; road(scenario,roadcenters)
ans = Road with properties: Name: "" RoadID: 3 RoadCenters: [2x3 double] RoadWidth: 6 BankAngle: [2x1 double] Heading: [2x1 double]

Get the road boundaries.

rbdry = roadBoundaries(scenario);

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.

plot(scenario,'Centerline','on','RoadCenters','on'); title('Scenario');

Figure contains an axes object. The axes object with title Scenario contains 1219 objects of type patch, line.

Display the actor poses and profiles.

poses = actorPoses(scenario)
提出了=2×1 struct array with fields:行为orID Position Velocity Roll Pitch Yaw AngularVelocity
profiles = actorProfiles(scenario)
profiles=2×1 struct array with fields:行为orID ClassID Length Width Height OriginOffset MeshVertices MeshFaces RCSPattern RCSAzimuthAngles RCSElevationAngles

Input Arguments

collapse all

Driving scenario, specified as adrivingScenarioobject.

Name-Value Arguments

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

Example:plot(sc,'Centerline','on','RoadCenters','on')displays the center line and road centers of each road segment.

Axes in which to draw the plot, specified as the comma-separated pair consisting of'Parent'and anAxesobject. If you do not specifyParent, a new figure is created.

Display the center line of roads, specified as the comma-separated pair consisting of'Centerline'and'off'or'on'. The center line follows the middle of each road segment. Center lines are discontinuous through areas such as intersections or road splits.

Display road centers, specified as the comma-separated pair consisting of'RoadCenters'and'off'or'on'. The road centers define the roads shown in the plot.

Display actor waypoints, specified as the comma-separated pair consisting of'Waypoints'and'off'or'on'. Waypoints define the trajectory of the actor.

Display actor meshes instead of cuboids, specified as the comma-separated pair consisting of'Meshes'and'off'or'on'.

行为ors around which to draw indicators, specified as the comma-separated pair consisting of'ActorIndicators'and a vector of行为orIDintegers. The driving scenario plot draws circles around the actors that have the specified行为orIDvalues. Each circle is the same color as the actor that it surrounds. The circles are not sensor coverage areas.

Use this name-value pair to highlight the ego vehicle in driving scenarios that contain several vehicles.

Display parking lot edge numbers, specified as the comma-separated pair consisting of'ParkingLotEdges'and'off'or'on'. The order of the edge numbers is based on the order of the vertices defined in each parking lot.

Tips

  • To rotate any plot, in the figure window, selectView>Camera Toolbar.

Version History

Introduced in R2017a