# plan

Plan vehicle path using RRT* path planner

## Syntax

``refPath = plan(planner,startPose,goalPose)``
``[refPath,tree] = plan(planner,startPose,goalPose)``

## Description

example

````refPath = plan(planner,startPose,goalPose)` plans a vehicle path from `startPose` to `goalPose` using the input `pathPlannerRRT` object. This object configures an optimal rapidly exploring random tree (RRT*) path planner.```
````[refPath,tree] = plan(planner,startPose,goalPose)` also returns the exploration tree, `tree`.```

## Examples

collapse all

Plan a vehicle path to a parking spot by using the RRT* algorithm.

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('parkingLotCostmapReducedInflation.mat'); costmap = data.parkingLotCostmapReducedInflation; plot(costmap)```

Define start and goal poses for the path planner as [x, y, Θ] vectors. World units for the (x,y) locations are in meters. World units for the Θ orientation values are in degrees.

```startPose = [11, 10, 0]; % [meters, meters, degrees] goalPose = [31.5, 17, 90];```

Create an RRT* path planner to plan a path from the start pose to the goal pose.

```planner = pathPlannerRRT(costmap); refPath = plan(planner,startPose,goalPose);```

Plot the planned path.

`plot(planner)`

## Input Arguments

collapse all

RRT* path planner, specified as a `pathPlannerRRT` object.

Initial pose of the vehicle, specified as an [x, y, Θ] vector. x and y are in world units, such as meters. Θ is in degrees.

Goal pose of the vehicle, specified as an [x, y, Θ] vector. x and y are in world units, such as meters. Θ is in degrees.

The vehicle achieves its goal pose when the last pose in the path is within the `GoalTolerance` property of `planner`.

## Output Arguments

collapse all

Planned vehicle path, returned as a `driving.Path` object containing reference poses along the planned path. If planning was unsuccessful, the path has no poses. To check if the path is still valid due to costmap updates, use the `checkPathValidity` function.

Exploration tree, returned as a `digraph` object. Nodes within `tree` represent explored vehicle poses. Edges within `tree` represent the distance between connected nodes.

## Version History

Introduced in R2018a