This is a 2D environment generator useful for random generation of random layouts in 2D. The implementation has been inspired by the environment description as specified in Appendix G of RoCUS. A few application where such an environment representation is useful are: environments for robot 2D navigation, obstacle grids, random meshes, maze generation, etc.
- Dynamic 2D Environment Generator
The environment is the area defined in the domain of (xmin, xmax) × (ymin, ymax) along with
starting point (xstart, ystart) and ending point (xgoal, ygoal). The environment representation is a
summation of radial basis function (RBF) kernels centered "obstacle points" that are randomly generated
based on a seed value. Specifically, given n obstacle points
A point P in the limits of the environment (xmin, xmax) × (ymin, ymax) is an obstacle if
- environment_range: (min limit, max limit) : the limits of the square environment.
- obstacle_point_range: (min limit, max limit) : points in the grid that can be obstacles.
- start_point: (start x, start y) : starting point in the environment.
- end_point: (end x, end y) : ending point in the enviropnment.
- obstacle_points: int ∈ (0, inf) : number of "obstacle points" for the kernel.
- eta: float : threshold (min weight) for classifying point as an obstacle.
- grid_resolution: int : resolution of grid for discretization.
- seed: int : a seed value for the psrng to generate the "obstacle points" kernels.
- gamma: int : weight for the RBF kernel.
To use the environment description from the environment.py
file, the following dependencies are required:
numpy
matplotlib
Additional requirements to generate environments in bulk using the main.py
file:
tqdm
Execute the main file using the command python main.py
from src as the working directory.
Note: make sure that the output file path exits.
matplotlib==3.1.2
numpy==1.17.4
tqdm==4.64.1
Install all requirements using pip install -r requirements.txt
from project source.
environment_range = (-1.2, 1.2)
obstacle_point_range = (-0.7, 0.7)
start_point = (-1, -1)
end_point = (1, 1)
obstacle_points = 15
eta = 0.9
grid_resolution = 500
seed = 1337 + offset (offset is set as per the image number)
gamma = 25
An archive of 5000+ environment layouts generated using the parameters listed above can be found at this link.