Main Content

plot

Plot planned vehicle path

Description

example

plot(refPath) plots the planned vehicle path.

plot(refPath,Name,Value) specifies options using one or more name-value pair arguments. For example, plot(path,'Vehicle','off') plots the path without displaying the vehicle.

Examples

collapse all

Plan a vehicle path through a parking lot by using the optimal rapidly exploring random tree (RRT*) algorithm. Check that the path is valid, and then plot the transition poses along the path.

Load a costmap of a parking lot. Plot the costmap to see the parking lot and inflated areas for the vehicle to avoid.

data = load('parkingLotCostmap.mat');
costmap = data.parkingLotCostmap;
plot(costmap)

Define start and goal poses for the vehicle as [x, y, Θ] vectors. World units for the (x,y) locations are in meters. World units for the Θ orientation angles are in degrees.

startPose = [4, 4, 90]; % [meters, meters, degrees]
goalPose = [30, 13, 0];

Use a pathPlannerRRT object to plan a path from the start pose to the goal pose.

planner = pathPlannerRRT(costmap);
refPath = plan(planner,startPose,goalPose);

Check that the path is valid.

isPathValid = checkPathValidity(refPath,costmap)
isPathValid = logical
   1

Interpolate the transition poses along the path.

transitionPoses = interpolate(refPath);

Plot the planned path and the transition poses on the costmap.

hold on
plot(refPath,'DisplayName','Planned Path')
scatter(transitionPoses(:,1),transitionPoses(:,2),[],'filled', ...
    'DisplayName','Transition Poses')
hold off

Input Arguments

collapse all

Planned vehicle path, specified as a driving.Path object.

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.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'Inflation','off'

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

Display vehicle, specified as the comma-separated pair consisting of 'Vehicle' and 'on' or 'off'. Setting this argument to 'on' displays the vehicle along the path.

Dimensions of the vehicle, specified as the comma-separated pair consisting of 'VehicleDimensions' and a vehicleDimensions object.

Name of the entry in the legend, specified as the comma-separated pair consisting of 'DisplayName' and a character vector or string scalar.

Path color, specified as the comma-separated pair consisting of 'Color' and a color name, short color name, or RGB triplet.

For a custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7]. Alternatively, you can specify some common colors by name. This table lists the named color options and the equivalent RGB triplet values.

Color NameColor Short NameRGB TripletAppearance
'red''r'[1 0 0]

Sample of the color red

'green''g'[0 1 0]

Sample of the color green

'blue''b'[0 0 1]

Sample of the color blue

'cyan' 'c' [0 1 1]

Sample of the color cyan

'magenta''m'[1 0 1]

Sample of the color magenta

'yellow''y'[1 1 0]

Sample of the color yellow

'black''k'[0 0 0]

Sample of the color black

'white''w'[1 1 1]

Sample of the color white

Example: 'Color',[1 0 1]

Example: 'Color','m'

Example: 'Color','magenta'

Tag to identify path, specified as the comma-separated pair consisting of 'Tag' and a character vector or string scalar.

Version History

Introduced in R2018a