Main Content


State validator based on 2-D costmap

Since R2019b


The validatorOccupancyMap object validates states and discretized motions based on the value in a 2-D costmap. An occupied map location is interpreted as an invalid state.




validator = validatorVehicleCostmap creates a vehicle cost map validator associated with an SE2 state space with default settings.


validator = validatorVehicleCostmap(stateSpace) creates a validator in the given state space definition derived from nav.StateSpace.

validator = validatorVehicleCostmap(stateSpace,Name,Value) specifies the Map or XYIndices properties using Name,Value pair arguments.


expand all

State space for validating states, specified as a subclass of nav.StateSpace. Provided state space objects include:

Map used for validating states, specified as a vehicleCostmap (Automated Driving Toolbox) object.

Interval for sampling between states and checking state validity, specified as a positive numeric scalar.

State variable mapping for xy-coordinates in state vector, specified as a two-element vector, [xIdx yIdx]. For example, if a state vector is given as [r p y x y z], the xy-coordinates are [4 5].

State variable mapping for theta coordinate in state vector, specified as a positive integer. For example, if a state vector is given as [x y theta], the theta coordinate is 3.

Object Functions

copyCreate deep copy of state validator object
isStateValidCheck if state is valid
isMotionValidCheck if path between states is valid


collapse all

This example shows how to validate paths through an environment.

Load example maps. Use the simple map to create a vehicle cost map. Specify an inflation radius of 1 meter.

load exampleMaps.mat
map = vehicleCostmap(double(simpleMap));
map.CollisionChecker = inflationCollisionChecker("InflationRadius",1);

Specify a coarse path through the map.

path = [3 3 pi/2; 8 15 0; 17 8 -pi/2];
hold on

Create a state validator using the stateSpaceSE2 definition. Specify the map and the distance for interpolating and validating path segments.

validator = validatorVehicleCostmap(stateSpaceSE2);
validator.Map = map;
validator.ValidationDistance = 0.1;

Check the points of the path are valid states. All three points are in free space, so are considered valid.

isValid = isStateValid(validator,path)
isValid = 3x1 logical array


Check the motion between each sequential path states. The isMotionValid function interpolates along the path between states. If a path segment is invalid, plot the last valid point along the path.

startStates = [path(1,:);path(2,:)];
endStates = [path(2,:);path(3,:)];
    for i = 1:2
        [isPathValid, lastValid] = isMotionValid(validator,startStates(i,:),endStates(i,:));
        if ~isPathValid
hold off

Extended Capabilities

Version History

Introduced in R2019b