Main Content

validatorOccupancyMap

State validator based on 2-D grid map

Since R2019b

Description

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

Creation

Syntax

Description

validator = validatorOccupancyMap creates a 2-D occupancy map validator associated with an SE2 state space with default settings.

example

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

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

Properties

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 binaryOccupancyMap or occupancyMap 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].

Object Functions

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

Examples

collapse all

This example shows how to validate paths through an environment.

Load example maps. Use the simple map to create a binary occupancy map.

load exampleMaps.mat
map = occupancyMap(simpleMap);
show(map)

Specify a coarse path through the map.

path = [2 2 pi/2; 10 15 0; 17 8 -pi/2];
hold on
plot(path(:,1),path(:,2),"--o")

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

validator = validatorOccupancyMap(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

   1
   1
   1

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
            plot(lastValid(1),lastValid(2),'or')
        end
    end
hold off

Extended Capabilities

Version History

Introduced in R2019b