plot
Plot planned vehicle path
Description
plot(
specifies options using one or more name-value pair arguments. For example,
refPath
,Name,Value
)plot(path,'Vehicle','off')
plots the path without
displaying the vehicle.
Examples
Plan Path and Check Its Validity
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
refPath
— Planned vehicle path
driving.Path
object
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'
Parent
— Axes object
axes
object
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.
Vehicle
— Display vehicle
'on'
(default) | 'off'
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.
VehicleDimensions
— Dimensions of vehicle
vehicleDimensions
object
Dimensions of the vehicle, specified as the comma-separated pair
consisting of 'VehicleDimensions'
and a vehicleDimensions
object.
DisplayName
— Name of entry in legend
''
(default) | character vector | string scalar
Name of the entry in the legend, specified as the comma-separated pair
consisting of 'DisplayName'
and a character vector or
string scalar.
Color
— Path color
color name | short color name | RGB triplet
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 Name | Color Short Name | RGB Triplet | Appearance |
---|---|---|---|
'red' | 'r' | [1 0 0] |
|
'green' | 'g' | [0 1 0] |
|
'blue' | 'b' | [0 0 1] |
|
'cyan'
| 'c'
| [0 1 1] |
|
'magenta' | 'm' | [1 0 1] |
|
'yellow' | 'y' | [1 1 0] |
|
'black' | 'k' | [0 0 0] |
|
'white' | 'w' | [1 1 1] |
|
Example: 'Color',[1 0 1]
Example: 'Color','m'
Example: 'Color','magenta'
Tag
— Tag to identify path
''
(default) | character vector | string scalar
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
See Also
Functions
Objects
Topics
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 (한국어)