Plan path between two states
Create a state space.
ss = stateSpaceSE2;
occupanyMap-based state validator using the created state space.
sv = validatorOccupancyMap(ss);
Create an occupany map from an example map and set map resolution as 10 cells/meter.
load exampleMaps map = occupancyMap(simpleMap,10); sv.Map = map;
Set validation distance for the validator.
sv.ValidationDistance = 0.01;
Update state space bounds to be the same as map limits.
ss.StateBounds = [map.XWorldLimits;map.YWorldLimits; [-pi pi]];
Create the path planner and increase max connection distance.
planner = plannerRRT(ss,sv); planner.MaxConnectionDistance = 0.3;
Set the start and goal states.
start = [0.5,0.5,0]; goal = [2.5,0.2,0];
Plan a path with default settings.
rng(100,'twister'); % for repeatable result [pthObj,solnInfo] = plan(planner,start,goal);
Visualize the results.
show(map) hold on plot(solnInfo.TreeData(:,1),solnInfo.TreeData(:,2),'.-'); % tree expansion plot(pthObj.States(:,1),pthObj.States(:,2),'r-','LineWidth',2) % draw path
startState— Start state of the path
Start state of the path, specified as an N-element real-valued vector. N is the dimension of the state space.
[1 1 pi/6]
goalState— Goal state of the path
Goal state of the path, specified as an N-element real-valued vector. N is the dimension of the state space.
[2 2 pi/3]
path— Object that holds planned path information
An object that holds the planned path information, returned as a
solutionInfo— Solution Information
Solution Information, returned as a structure. The fields of the structure are:
|Indicates whether a path is found. It returns as |
Indicates the terminate status of the planner, returned as
|Number of nodes in the search tree when the planner terminates (excluding the root node).|
|Number of "extend" routines executed.|
|A collection of explored states that reflects the status of the search tree
when planner terminates. Note that |
Contains the cost of the path at each iteration. Value for iterations
when path has not reached the goal is denoted by a
This field is applicable only for