Information for path metrics


The pathmetrics object holds information for computing path metrics. Use object functions to calculate smoothness, clearance, and path validity based on a set of poses and the associated map environment.



pathMetricsObj = pathmetrics(path) creates an object based on the input navPath object. The state validator is assumed to be a validatorOccupancyMap object. The path input sets the value of the Path property.


pathMetricsObj = pathmetrics(path,validator) creates an object based on the input navPath object and associated state validator for checking the path validity. The validator input sets the value of the StateValidator property.


expand all

Path data structure, specified as a navPath object is the path whose metric is to be calculated.

Validator for states on path, specified as a validatorOccupancyMap object that validates the states and discretized motions based on the values in a 2-D occupancy map.

Object Functions

clearanceMinimum clearance of path
isPathValidDetermine if planned path is obstacle free
showVisualize path metrics in map environment
smoothnessSmoothness of path


collapse all

Compute smoothness, clearance, and validity of a planned path based on a set of poses and the associated map environment.

Load and Assign Map to State Validator

Create an occupancy map from an example map and set the map resolution.

load exampleMaps.mat; % simpleMap
mapResolution = 1; % cells/meter
map = occupancyMap(simpleMap,mapResolution);

Create a Dubins state space.

statespace = stateSpaceDubins;

Create a state validator based on occupancy map to store the parameters and states in the Dubins state space.

statevalidator = validatorOccupancyMap(statespace);

Assign the map to the validator.

statevalidator.Map = map;

Set the validation distance for the validator.

statevalidator.ValidationDistance = 0.01;

Update the state space bounds to be the same as the map limits.

statespace.StateBounds = [map.XWorldLimits;map.YWorldLimits;[-pi pi]];

Plan Path

Create an RRT* path planner and allow further optimization.

planner = plannerRRTStar(statespace,statevalidator);
planner.ContinueAfterGoalReached = true;

Reduce the maximum number of iterations and increase the maximum connection distance.

planner.MaxIterations = 2500;
planner.MaxConnectionDistance = 0.3;

Define start and goal states for the path planner as [x, y, theta] vectors. x and y are the Cartesian coordinates, and theta is the orientation angle.

start = [2.5, 2.5, 0]; % [meters, meters, radians]
goal = [22.5, 8.75, 0];

Plan a path from the start state to the goal state. The plan function returns a navPath object.

rng(100,'twister') % repeatable result
[path,solutionInfo] = plan(planner,start,goal);

Compute and Visualize Path Metrics

Create a path metrics object.

pathMetricsObj = pathmetrics(path,statevalidator);

Check path validity. The result is 1 (true) if the planned path is obstacle free. 0 (false) indicates an invalid path.

ans = logical


Calculate the minimum clearance of the path.

ans = 

Evaluate the smoothness of the path. Values close to 0 indicate a smoother path. Straight-line paths return a value of 0.

ans = 

Visualize the minimum clearance of the path.

legend('Planned Path','Minimum Clearance')

Introduced in R2019b