Main Content

validatorOccupancyMap

State validator based on 2-D grid map

Description

ThevalidatorOccupancyMapobject 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= validatorOccupancyMapcreates 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 fromnav.StateSpace.

validator= validatorOccupancyMap(stateSpace,Name,Value)specifies theMaporXYIndicesproperties usingName,Value对参数。

Properties

expand all

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

Map used for validating states, specified as abinaryOccupancyMaporoccupancyMapobject.

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

State variable mapping forxy-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],xy-coordinates are[4 5].

Object Functions

copy Create deep copy of state validator object
isStateValid Check if state is valid
isMotionValid Check if path between states is valid

Examples

collapse all

This example shows how to validate paths through an evironment.

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

loadexampleMaps.matmap = occupancyMap(simpleMap); show(map)

Figure contains an axes object. The axes object with title Occupancy Grid contains an object of type image.

Specify a coarse path through the map.

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

Figure contains an axes object. The axes object with title Occupancy Grid contains 2 objects of type image, line.

Create a state validator using thestateSpaceSE2definition. 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 array1 1 1

Check the motion between each sequential path states. TheisMotionValidfunction 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,:)];fori = 1:2 [isPathValid, lastValid] = isMotionValid(validator,startStates(i,:),endStates(i,:));if~isPathValid plot(lastValid(1),lastValid(2),'or')endendholdoff

Figure contains an axes object. The axes object with title Occupancy Grid contains 3 objects of type image, line.

Extended Capabilities

Introduced in R2019b