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 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
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 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 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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)