plannerRRT

Create an RRT planner for geometric planning

Description

The plannerRRT object creates a rapidly-exploring random tree (RRT) planner for solving geometric planning problems. RRT is a tree-based motion planner that builds a search tree incrementally from samples randomly drawn from a given state space. The tree eventually spans the search space and connects the start state to the goal state. The general tree growing process is as follows:

  1. The planner samples a random state xrand in the state space.

  2. The planner finds a state xnear that is already in the search tree and is closest (based on the distance definition in the state space) to xrand.

  3. The planner expands from xnear towards xrand, until a state xnew is reached.

  4. Then new state xnew is added to the search tree.

For geometric RRT, the expansion and connection between two states can be found analytically without violating the constraints specified in the state space of the planner object.

Creation

Description

example

planner = plannerRRT(stateSpace,stateVal) creates an RRT planner from a state space object, stateSpace, and a state validator object, stateVal. The state space of stateVal must be the same as stateSpace. stateSpace and stateVal also sets the StateSpace and StateValidator properties of the planner.

Properties

expand all

State space for the planner, specified as a state space object. You can use state space objects such as stateSpaceSE2, stateSpaceDubins, and stateSpaceReedsShepp. You can also customize a state space object using the nav.StateSpace object.

Data Types: object

State validator for the planner, specified as a state validator object. You can use state validator objects such as validatorOccupancyMap and validatorVehicleCostmap .

Data Types: object

Maximum number of nodes in the search tree, specified as a positive integer.

Data Types: single | double

Maximum number of iterations, specified as a positive integer.

Data Types: single | double

Maximum length of a motion allowed in the tree, specified as a scalar.

Data Types: single | double

Callback function to evaluate whether the goal is reached, specified as a function handle. You can create your own goal reached function. The function must follow this syntax:

 function isReached = myGoalReachedFcn(planner,currentState,goalState)

where:

  • planner — The created planner object, specified as plannerRRT object.

  • currentState — The current state, specified as a three element real vector.

  • goalState — The goal state, specified as a three element real vector.

  • isReached — A boolean variable to indicate whether the current state has reached the goal state, returned as true or false.

Data Types: function handle

Probability of choosing the goal state during state sampling, specified as a real scalar in [0,1]. The property defines the probability of choosing the actual goal state during the process of randomly selecting states from the state space. You can start by setting the probability to a small value such as 0.05.

Data Types: single | double

Object Functions

planPlan path between two states
copyCreate copy of planner object

Examples

collapse all

Create a state space.

ss = stateSpaceSE2;

Create an 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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2019b