Main Content

mapClutter

Generate map with randomly scattered obstacles

Since R2020b

Description

map = mapClutter generates a 2-D occupancy map as a binaryOccupancyMap object map, with a width and height of 50 meters and a resolution of 5 cells per meter. The map contains 20 randomly distributed obstacles of types Box and Circle. Generated obstacles have random sizes.

map = mapClutter(numObst) generates a 2-D occupancy map, of the default size and resolution, with a specified number of randomly distributed obstacles, numObst, of default shapes.

map = mapClutter(numObst,shapes) generates a 2-D occupancy map, of the default size and resolution, with a specified number of obstacles, numObst, of specified shapes, shapes.

map = mapClutter(___,Name,Value) specifies options using one or more name-value pair arguments in addition to any combination of input arguments from previous syntaxes. For example, 'MapSize',[50 30] generates a randomly distributed obstacle map with a width of 50 meters and height of 30 meters.

example

Examples

collapse all

Generate a 2-D occupancy map with ten randomly scattered obstacles of types Box, Circle, and Plus. Specify the size of the map as 50 meters wide and 30 meters high with a resolution of 5 cells per meters.

map = mapClutter(10,{'Box','Plus','Circle'},'MapSize',[50 30],'MapResolution',5);

Visualize the generated obstacle map.

show(map)

Figure contains an axes object. The axes object with title Binary Occupancy Grid, xlabel X [meters], ylabel Y [meters] contains an object of type image.

Input Arguments

collapse all

Number of obstacles, specified as a positive integer.

Data Types: single | double

Obstacle shapes, specified as a string scalar, character vector, string array, or cell array of character vectors. The only valid shapes are Box, Circle, and Plus.

When you specify a string scalar or a character vector, the function generates a map with obstacles of only the specified shape.

Example: "Box"

Example: 'Box'

When you specify a string array or a cell array of character vectors, the function generates a map with obstacles of each specified shape.

Example: ["Box","Plus"]

Example: {'Box','Plus','Circle'}

Data Types: cell | string | char

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'MapSize',[50 40] generates a randomly distributed obstacle map with a width of 50 meters and height of 40 meters.

Width and height of the generated map, specified as the comma-separated pair consisting of 'MapSize' and a two-element vector of positive real finite numbers of the form [Width,Height]. Specify both values in meters.

Example: 'MapSize',[50 30]

Data Types: single | double

Resolution of the generated map, specified as the comma-separated pair consisting of 'MapResolution' and a positive real scalar in cells per meter.

Example: 'MapResolution',10

Data Types: single | double

Output Arguments

collapse all

A map with randomly scattered obstacles, returned as a binaryOccupancyMap object.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2020b