diff --git a/.gitignore b/.gitignore index 4f7687709..2a4cff0b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # TODOs experiments/SVS_Code/3D_Models/ experiments/SVS_Code/tenere/ +experiments/SVS_Code/environment_generator/generated_envs TODOs.md examples/debug.py diff --git a/experiments/SVS_Code/environment_generator/generate_multiple.py b/experiments/SVS_Code/environment_generator/generate_multiple.py new file mode 100644 index 000000000..cebee1e34 --- /dev/null +++ b/experiments/SVS_Code/environment_generator/generate_multiple.py @@ -0,0 +1,32 @@ +# +# python-edition of "generate_multiple.bash" +# +# usage: +# > python generate_multiple.py N DENSITY_MULTIPLIER +# + +import sys +import os +import argparse +import shutil +import random + +parser = argparse.ArgumentParser(description='Generate multiple environments') +parser.add_argument("N", help="Number of environments, e.g. 10", + default=10, type=int) +parser.add_argument("DENSITY_MULTIPLIER", help="DENSITY_MULTIPLIER, e.g. 0.5(easy), 1.0(medium), or 1.5(hard)", + default=1.0, type=float) +args = parser.parse_args() + +homepath = os.path.dirname(__file__) +generated_envs_path = os.path.join(homepath, "generated_envs") + +if os.path.exists(generated_envs_path): + shutil.rmtree(generated_envs_path, ignore_errors=True) + +for i in range(args.N): + thispath = os.path.join(generated_envs_path, f"environment_{i}") + os.makedirs(thispath) + os.system( + f"python {homepath}/obstacle_generator.py {random.randint(0,32767)} {args.DENSITY_MULTIPLIER}") + shutil.move(os.path.join(homepath, "static_obstacles.csv"), thispath) diff --git a/experiments/SVS_Code/environment_generator/obstacle_generator.py b/experiments/SVS_Code/environment_generator/obstacle_generator.py index 858f5436a..75ce25642 100755 --- a/experiments/SVS_Code/environment_generator/obstacle_generator.py +++ b/experiments/SVS_Code/environment_generator/obstacle_generator.py @@ -239,12 +239,13 @@ def toCSV(self): d["N"] = len(d.keys()) - with open("static_obstacles.csv", "w") as f: + with open(os.path.join(os.path.dirname(__file__), "static_obstacles.csv"), "w") as f: f.write("\n".join(static_obstacles)) if __name__ == "__main__": - with open("obstacle_config.yaml") as f: + + with open(os.path.join(os.path.dirname(__file__), "obstacle_config.yaml")) as f: config = yaml.safe_load(f) w = World(config) w.toCSV() diff --git a/pyproject.toml b/pyproject.toml index d2a032ae5..b5ed270ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ matplotlib = "^3.5" cycler = "^0.10" gym = "^0.21" pybullet = "^3.2" -torch = "1.11.0" +# torch = "1.11.0" # if you want to use GPU, please manually install it "ray[rllib]" = "1.9" stable-baselines3 = "1.5.0" scipy = "^1.8"