Plot planned vehicle path
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.
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
refPath
— Planned vehicle pathdriving.Path
objectPlanned vehicle path, specified as a driving.Path
object.
Specify optional
comma-separated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
'Inflation','off'
'Parent'
— Axes objectaxes
objectAxes 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 vehiclevehicleDimensions
objectDimensions 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 scalarName of the entry in the legend, specified as the comma-separated pair
consisting of 'DisplayName'
and a character vector or
string scalar.
'Color'
— Path colorPath 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 scalarTag to identify path, specified as the comma-separated pair consisting
of 'Tag'
and a character vector or string scalar.
You have a modified version of this example. Do you want to open this example with your edits?