-
Notifications
You must be signed in to change notification settings - Fork 162
/
env.py
80 lines (79 loc) · 3.07 KB
/
env.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import numpy as np
import gym
def make_env(env_name, seed=-1, render_mode=False):
if (env_name.startswith("RacecarBulletEnv")):
import pybullet as p
import pybullet_envs
import pybullet_envs.bullet.racecarGymEnv as racecarGymEnv
print("bullet_racecar_started")
env = racecarGymEnv.RacecarGymEnv(isDiscrete=False, renders=render_mode)
elif (env_name.startswith("RocketLander")):
from box2d.rocket import RocketLander
env = RocketLander()
elif (env_name.startswith("BipedalWalker")):
if (env_name.startswith("BipedalWalkerHardcore")):
from box2d.biped import BipedalWalkerHardcore
env = BipedalWalkerHardcore()
else:
from box2d.biped import BipedalWalker
env = BipedalWalker()
elif (env_name.startswith("MinitaurBulletEnv")):
import pybullet as p
import pybullet_envs
import pybullet_envs.bullet.minitaur_gym_env as minitaur_gym_env
print("bullet_minitaur_started")
env = minitaur_gym_env.MinitaurBulletEnv(render=render_mode)
elif (env_name.startswith("MinitaurDuckBulletEnv")):
print("bullet_minitaur_duck_started")
import pybullet as p
import pybullet_envs
from custom_envs.minitaur_duck import MinitaurDuckBulletEnv
env = MinitaurDuckBulletEnv(render=render_mode)
elif (env_name.startswith("MinitaurBallBulletEnv")):
print("bullet_minitaur_ball_started")
import pybullet as p
import pybullet_envs
from custom_envs.minitaur_ball import MinitaurBallBulletEnv
env = MinitaurBallBulletEnv(render=render_mode)
elif (env_name.startswith("SlimeVolley")):
print("slimevolley_swingup_started")
from custom_envs.slimevolley import SlimeVolleyEnv, SurvivalRewardEnv
env = SlimeVolleyEnv()
env = SurvivalRewardEnv(env) # optional
elif (env_name.startswith("CartPoleSwingUp")):
print("cartpole_swingup_started")
from custom_envs.cartpole_swingup import CartPoleSwingUpEnv
env = CartPoleSwingUpEnv()
elif (env_name.startswith("KukaBulletEnv")):
import pybullet as p
import pybullet_envs
import pybullet_envs.bullet.kukaGymEnv as kukaGymEnv
print("bullet_kuka_grasping started")
env = kukaGymEnv.KukaGymEnv(renders=render_mode,isDiscrete=False)
elif (env_name.startswith("NoDeathAntBullet")):
print("no death bullet ant.")
import pybullet_envs
from custom_envs.custom_wrapper import NoDeath
env = NoDeath(gym.make("AntBulletEnv-v0"))
if render_mode and not env_name.startswith("Roboschool"):
env.render("human")
else:
if env_name.startswith("Roboschool"):
import roboschool
if "Bullet" in env_name:
import pybullet_envs
env = gym.make(env_name)
if render_mode and not env_name.startswith("Roboschool"):
env.render("human")
if (seed >= 0):
env.seed(seed)
'''
print("environment details")
print("env.action_space", env.action_space)
print("high, low", env.action_space.high, env.action_space.low)
print("environment details")
print("env.observation_space", env.observation_space)
print("high, low", env.observation_space.high, env.observation_space.low)
assert False
'''
return env