plannerLineSpec.goalTree
Syntax
Description
specifies
default color, line, and marker properties for plotting the search tree from goal to
start.spec = plannerLineSpec.goalTree
specifies new values for the color, line, and marker properties by using one or more
name-value arguments.spec = plannerLineSpec.goalTree(Name=Value)
[
returns the properties and their values as a structure using any combination of inputs
from the previous syntaxes.spec,structData] = plannerLineSpec.goalTree(___)
Examples
Load Occupancy Map
Load a probability occupancy grid into the MATLAB® workspace.
load("exampleMaps.mat","simpleMap")
Create an occupancy map from the input occupancy grid.
map = occupancyMap(simpleMap);
Define the lower and upper limits of the state space variables x, y, and theta from the occupancy map.
x = map.XWorldLimits; y = map.YWorldLimits; theta = [-pi pi];
Specify the start state and the goal state for path planning.
start = [2 5 0]; goal = [22 22 0];
Display the occupancy map.
figure
show(map)
hold onPlot Start and Goal States
Use the plannerLineSpec.start and plannerLineSpec.goal functions to plot the start and goal states, respectively.
plot(start(1),start(2),plannerLineSpec.start{:})
plot(goal(1),goal(2),plannerLineSpec.goal{:})![Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains 3 objects of type image, line. One or more of the lines displays its values using only markers These objects represent Start, Goal.](../../examples/nav/win64/VisualizeBiRRTPlannerOutputUsingDefaultPlotSpecExample_01.png)
Configure Bi-RRT Path Planner and Find Path Between Two States
Create a state space SE(2) object using the specified state space variables.
stateSpace = stateSpaceSE2([x; y; theta]);
Check the validity of the states in the input state space by using a state validator.
stateValidator = validatorOccupancyMap(stateSpace,Map=map);
Configure the Bi-RRT path planner.
planner = plannerBiRRT(stateSpace,stateValidator);
Compute the path between the start point and the goal point using Bi-RRT path planner.
[path,info] = plan(planner,start,goal)
path =
navPath with properties:
StateSpace: [1×1 stateSpaceSE2]
States: [306×3 double]
NumStates: 306
MaxNumStates: Inf
info = struct with fields:
IsPathFound: 1
ExitFlag: 1
NumIterations: 294
StartTreeData: [569×3 double]
GoalTreeData: [710×3 double]
StartTreeNumNodes: 189
GoalTreeNumNodes: 236
Plot Search Trees
Use the plannerLineSpec.tree function to plot the forward search tree.
startTree = plannerLineSpec.tree;
plot(info.StartTreeData(:,1),info.StartTreeData(:,2),startTree{:})Use the plannerLineSpec.goalTree function to plot the search tree from the goal state to the start state. Set the line color for plotting the search tree from goal to start to cyan.
goalTree = plannerLineSpec.goalTree(color="cyan");
plot(info.GoalTreeData(:,1),info.GoalTreeData(:,2),goalTree{:})
legendPlot Computed Path
Use the plannerLineSpec.path function to plot the derived path.
plot(path.States(:,1),path.States(:,2),plannerLineSpec.path{:})
legend(Position=[0.8 0.11 0.2 0.2])![Figure contains an axes object. The axes object with title Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains 6 objects of type image, line. One or more of the lines displays its values using only markers These objects represent Start, Goal, Tree, Goal Tree, Path.](../../examples/nav/win64/VisualizeBiRRTPlannerOutputUsingDefaultPlotSpecExample_02.png)
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.
Example:
plannerLineSpec.goalTree(Color="Red")
Line color, specified as one of these values:
RGB triplet — Specify the intensities of the red, green, and blue components of the color as a three-element vector in the order
[R G B]. Each intensity must be in the range [0, 1]. For example, you can specify a shade of pink as[1 0.5 0.8].Character vector or string scalar — Specify the hexadecimal color code, color name, or short name of the color.
For more information on the types of color values and how to specify them, see Specify Plot Colors.
Line style, specified as one of these values:
"-"— For a solid line. This is the default."--"— For a dashed line.":"— For a dotted line."-."— For a dash-dotted line."none"— For no line.
Line width, specified as a positive numeric scalar.
Marker symbol, specified as one of the values listed in this table.
| Marker | Description | Resulting Marker |
|---|---|---|
"o"
| Circle |
|
"+"
| Plus sign |
|
"*"
| Asterisk |
|
"."
| Point |
|
"x"
| Cross |
|
"_"
| Horizontal line |
|
"|"
| Vertical line |
|
"square"
| Square |
|
"diamond"
| Diamond |
|
"^"
| Upward-pointing triangle |
|
"v"
| Downward-pointing triangle |
|
">"
| Right-pointing triangle |
|
"<"
| Left-pointing triangle |
|
"pentagram"
| Pentagram |
|
"hexagram"
| Hexagram |
|
"none"
| No markers | Not applicable |
Marker size, specified as a positive numeric scalar.
Marker outline color, specified as one of these values:
RGB triplet — Specify the intensities of the red, green, and blue components of the color as a three-element vector in the order
[R G B]. Each intensity must be in the range [0, 1]. For example, you can specify a shade of pink as[1 0.5 0.8].Character vector or string scalar — Specify the hexadecimal color code, color name, or short name of the color.
For more information on the types of color values and how to specify them, see Specify Plot Colors.
Marker fill color, specified as one of these values:
RGB triplet — Specify the intensities of the red, green, and blue components of the color as a three-element vector in the order
[R G B]. Each intensity must be in the range [0, 1]. For example, you can specify a shade of pink as[1 0.5 0.8].Character vector or string scalar — Specify the hexadecimal color code, color name, or short name of the color.
For more information on the types of color values and how to specify them, see Specify Plot Colors.
Label to include in the legend, specified as a character vector or string scalar.
Output Arguments
Color, line, and marker specifications for plotting the search tree from goal to start, returned as a cell array of size 1-by-16.
Data Types: cell
Specifications for the plot, returned as a structure with fields
Color, LineStyle,
LineWidth, Marker,
MarkerSize, MarkerEdgecolor,
MarkerFaceColor, and DisplayName. Each
field contains the value specified to the corresponding name-value
argument.
Data Types: struct
Version History
Introduced in R2023b
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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)