Main Content

plan

Find obstacle-free path between two poses

Description

example

path = plan(planner,start,goal) computes an obstacle-free path between start and goal poses, specified as [x y theta] vectors, using the input plannerHybridAStar object.

[path,directions] = plan(planner,start,goal) also returns the direction of motion for each pose along the path, directions, as a column vector. A value of 1 indicates forward direction and a value of -1 indicates reverse direction. The function returns an empty column vector when the planner is unable to find a path.

[path,directions,solutionInfo] = plan(planner,start,goal) also returns solutionInfo that contains the solution information of the path planning as a structure.

Examples

collapse all

Plan a collision-free path for a vehicle through a parking lot by using the Hybrid A* algorithm.

Create and Assign Map to State Validator

Load the cost values of cells in the vehicle costmap of a parking lot.

load parkingLotCostVal.mat % costVal

Create a binaryOccupancyMap with cost values.

map = binaryOccupancyMap(costVal);

Create a state validator object for collision checking.

validator = validatorOccupancyMap;

Assign the map to the state validator object.

validator.Map = map;

Plan and Visualize Path

Initialize the plannerHybridAStar object with the state validator object. Specify the MinTurningRadius and MotionPrimitiveLength properties of the planner.

planner = plannerHybridAStar(validator,'MinTurningRadius',4,'MotionPrimitiveLength',6);

Define start and goal poses for the vehicle as [x, y, theta] vectors. x and y specify the position in meters, and theta specifies the orientation angle in radians.

startPose = [6 10 pi/2]; % [meters, meters, radians]
goalPose = [90 54 -pi/2];

Plan a path from the start pose to the goal pose.

refpath = plan(planner,startPose,goalPose);

Visualize the path using show function.

show(planner)

Figure contains an axes object. The axes object with title Hybrid A* Path Planner contains 6 objects of type image, line, scatter. These objects represent Forward Motion Primitives, Reverse Motion Primitives, Forward Path, Start, Goal.

Input Arguments

collapse all

Hybrid A* path planner, specified as a plannerHybridAStar object.

Start location of path, specified as a 1-by-3 vector in the form [x y theta]. x and y specify the position in meters, and theta specifies the orientation angle in radians.

Example: [5 5 pi/2]

Data Types: double

Final location of path, specified as a 1-by-3 vector in the form [x y theta]. x and y specify the position in meters, and theta specifies the orientation angle in radians.

Example: [45 45 pi/4]

Data Types: double

Output Arguments

collapse all

Obstacle-free path, returned as a navPath object.

Direction of motion for each pose along the path, returned as a column vector of 1s (forward) and –1s (reverse).

Data Types: double

Solution Information, returned as a structure. The fields of the structure are:

Fields of solutionInfo

FieldsDescription
IsPathFoundIndicates whether a path is found. It returns as 1 if a path is found. Otherwise, it returns 0.
NumNodesNumber of nodes in the search tree when the planner terminates (excluding the root node).
NumIterationsNumber of planning iterations executed.

Data Types: struct

Extended Capabilities

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

Introduced in R2019b