Main Content

mapMaze

Generate random 2-D maze map

Since R2021a

    Description

    map = mapMaze generates a random 2-D maze map, map, as a binaryOccupancyMap object with a width and height of 50 meters and a resolution of 5 cells per meter. The maze map contains straight passages, turns, and T-junctions with a passage width of 4 grid cells and wall thickness of 1 grid cell.

    map = mapMaze(passageWidth) generates a binaryOccupancyMap of a maze of the default size and resolution with a specified passage width, passageWidth, in number of grid cells.

    map = mapMaze(passageWidth,wallThickness) specifies a wall thickness, wallThickness, in number of grid cells.

    map = mapMaze(___,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 random maze map with a width of 50 meters and height of 30 meters.

    example

    Examples

    collapse all

    Generate a random 2-D maze map with a passage width of 5 grid cells and wall thickness of 2 grid cells. Specify the size of the map as 50 meters wide and 30 meters high with a resolution of 5 cells per meter.

    map = mapMaze(5,2,'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

    Width of maze passage, specified as a positive integer in number of grid cells.

    Data Types: single | double

    Thickness of maze wall, specified as a positive integer in number of grid cells.

    Data Types: single | double

    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

    Random maze map, returned as a binaryOccupancyMap object.

    Tips

    • when the number of grid cells along map width could not accommodate given maze parameters, ceil(MapWidth*MapResolution) must be greater than or equal to (passageWidth+2*wallThickness).

    • when the number of grid cells along map height could not accommodate given maze parameters, ceil(MapHeight*MapResolution) must be greater than or equal to (passageWidth+2*wallThickness).

    Version History

    Introduced in R2021a