Main Content

mapMaze

Generate random 2-D maze map

    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.

    example

    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.

    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)

    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 comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

    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).

    Introduced in R2021a