Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload "generate_multiple.py" which also support Windows #2

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 32 additions & 0 deletions experiments/SVS_Code/environment_generator/generate_multiple.py
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down