Main Content


Visualize the planned path



show(planner) plots the Hybrid A* expansion tree and the planned path in the map.

show(planner,Name,Value) specifies additional options using one or more name-value pair arguments.

axHandle = show(planner) outputs the axes handle of the figure used to plot the path.


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.


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.

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Positions','none'

Axes used to plot path, specified as the comma-separated pair consisting of 'Parent' and either an axes or uiaxes object. If you do not specify 'Parent', a new figure is created.

Display expansion tree option, specified as the comma-separated pair consisting of 'Tree' and either 'on' or 'off'.

Example: show(planner,'Tree','off')

Data Types: string

Display planned path option, specified as the comma-separated pair consisting of 'Path' and either 'on' or 'off'.

Example: show(planner,'Path','off')

Data Types: string

Display the start and goal points, specified as the comma-separated pair consisting of 'Positions' and one of the following:

  • 'start' — Display the start point.

  • 'goal' — Display the goal point.

  • 'both' — Display the start and goal points.

  • 'none' — Do not display any points.

Example: show(planner,'Positions','start')

Data Types: string

Output Arguments

collapse all

Axes used to plot path, returned as either an axes or uiaxes object.

Introduced in R2019b