addPlanner
Syntax
Description
addPlanner(
adds the plan function of a planner as a function handle plannerBM
,planFcn
)planFcn
to the
plannerBenchmark
object.
addPlanner(
also adds the initialization function of a planner as a function handle
plannerBM
,planFcn
,initializationFcn
)initializationFcn
to the plannerBenchmark
object.
addPlanner(___,
specifies options using one or more name-value arguments in addition to any combination of
input arguments from previous syntaxes.Name=Value
)
Examples
Benchmark 2-D Path Planners
Create an occupancy map from an example map.
load("exampleMaps.mat","simpleMap"); map = occupancyMap(simpleMap);
Create a state validator with stateSpaceSE2
using the map.
sv = validatorOccupancyMap(stateSpaceSE2,Map=map);
Specify the start and goal states.
start = [5 8 pi/2]; goal = [7 18 pi/2];
Create a plannerBenchmark
object.
pbo = plannerBenchmark(sv,start,goal);
Define the function handles for the initialization functions of the planners.
plannerHAFcn = @(sv)plannerHybridAStar(sv); plannerRRTSFcn = @(sv)plannerRRTStar(sv.StateSpace,sv);
Define the function handle for the plan function, which is common for both planners.
plnFcn = @(initOut,s,g)plan(initOut,s,g);
Add the path planners for benchmarking.
addPlanner(pbo,plnFcn,plannerHAFcn);
addPlanner(pbo,plnFcn,plannerRRTSFcn,PlannerName="ppRRTStar");
Set the rng
for repetitive results.
rng('default')
Run the path planners for the number of times specified in runCount
to collect metrics.
runCount = 5; runPlanner(pbo,runCount)
Initializing plannerHAFcn_plnFcn ... Done. Planning a path from the start pose (5 8 1.5708) to the goal pose (7 18 1.5708) using plannerHAFcn_plnFcn. Executing run 1. Executing run 2. Executing run 3. Executing run 4. Executing run 5. Initializing ppRRTStar ... Done. Planning a path from the start pose (5 8 1.5708) to the goal pose (7 18 1.5708) using ppRRTStar. Executing run 1. Executing run 2. Executing run 3. Executing run 4. Executing run 5.
Access path length metric for all the runs on the environment.
[pLenSummary,pLenData] = metric(pbo,"pathLength")
pLenSummary=2×4 table
Mean Median StdDev sampleSize
______ ______ _______ __________
plannerHAFcn_plnFcn 10.349 10.349 0 5
ppRRTStar 12.84 12.9 0.67112 5
pLenData=2×5 table
Run1 Run2 Run3 Run4 Run5
______ ______ ______ ______ ______
plannerHAFcn_plnFcn 10.349 10.349 10.349 10.349 10.349
ppRRTStar 13.8 12.9 12.2 12 13.3
Visualize all the metrics.
show(pbo)
Closely inspect the clearance metric.
figure
show(pbo,"clearance")
Input Arguments
plannerBM
— Path planner benchmark
plannerBenchmark
object
Path planner benchmark, specified as a plannerBenchmark
object.
planFcn
— Plan function of path planner
function handle
Plan function of path planner, specified as a function handle.
The function handle should be of the form,
@(initOut,start,goal)planFcn(...)
, where initOut
is the output of the initialization function.
If the initializationFcn
input is not specified, the function
handle should be @(env,start,goal)planFcn(...)
, where
env
is the Environment
property of plannerBenchmark
object.
The first output of planFcn
must be either a
navPath
object, m-by-2, or
m-by-3 matrix.
Data Types: function_handle
initializationFcn
— Initialization function of path planner
function handle
Initialization function of path planner, specified as a function handle.
The function handle should be of the form,
@(env)initializationFcn(...)
, where env
is the
Environment
property of plannerBenchmark
object.
The output of initializationFcn
is the first input to the
planFcn
function handle.
Data Types: function_handle
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: addPlanner(pbo,plnFcn,plannerRRTSFcn,PlannerName="ppRRTStar")
PlannerName
— Name of planner
character vector | string scalar
Name of planner, specified as character vector or string scalar.
The default planner name depends on one of the following,
If workspace variable name of
initializationFcn
andplanFcn
areinitVar
andplanVar
, respectively, the default planner name will be"initVar_planVar"
.If the optional
initializationFcn
input is not specified then the default planner name will be"planVar"
.If the function handles are specified as anonymous functions directly inside the
addPlanner
function, the default planner name will be"CustomInitFcn_CustomPlanFcn"
.If the optional
initializationFcn
input is not specified and theplanFcn
function handle is specified as an anonymous function directly then the default planner name will be"CustomPlanFcn"
.
Data Types: char
| string
NumPlanOutput
— Number of expected output from plan function
1
(default) | positive scalar
Number of expected output from plan function, specified as a positive scalar.
Data Types: single
| double
Version History
Introduced in R2022a
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 (한국어)