move pybullet.connect into the Gym environment.
If you like to enable rendering, call the env.render(mode="human") before calling the first env.reset
This commit is contained in:
@@ -30,14 +30,10 @@ class SmallReactivePolicy:
|
||||
|
||||
def main():
|
||||
env = gym.make("AntBulletEnv-v0")
|
||||
|
||||
cid = p.connect(p.GUI)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)
|
||||
env.render(mode="human")
|
||||
|
||||
pi = SmallReactivePolicy(env.observation_space, env.action_space)
|
||||
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
torsoId = -1
|
||||
for i in range (p.getNumBodies()):
|
||||
print(p.getBodyInfo(i))
|
||||
@@ -49,10 +45,8 @@ def main():
|
||||
frame = 0
|
||||
score = 0
|
||||
restart_delay = 0
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
obs = env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
|
||||
|
||||
while 1:
|
||||
time.sleep(0.001)
|
||||
a = pi.act(obs)
|
||||
|
||||
@@ -29,15 +29,11 @@ class SmallReactivePolicy:
|
||||
|
||||
def main():
|
||||
env = gym.make("HalfCheetahBulletEnv-v0")
|
||||
|
||||
cid = p.connect(p.GUI)
|
||||
env.render(mode="human")
|
||||
|
||||
pi = SmallReactivePolicy(env.observation_space, env.action_space)
|
||||
#disable rendering during reset, makes loading much faster
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
torsoId = -1
|
||||
for i in range (p.getNumBodies()):
|
||||
print(p.getBodyInfo(i))
|
||||
@@ -52,10 +48,8 @@ def main():
|
||||
frame = 0
|
||||
score = 0
|
||||
restart_delay = 0
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
obs = env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
|
||||
|
||||
while 1:
|
||||
time.sleep(0.001)
|
||||
a = pi.act(obs)
|
||||
|
||||
@@ -32,13 +32,10 @@ class SmallReactivePolicy:
|
||||
|
||||
def main():
|
||||
env = gym.make("HopperBulletEnv-v0")
|
||||
|
||||
cid = p.connect(p.GUI)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)
|
||||
env.render(mode="human")
|
||||
|
||||
pi = SmallReactivePolicy(env.observation_space, env.action_space)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
for i in range (p.getNumBodies()):
|
||||
print(p.getBodyInfo(i))
|
||||
if (p.getBodyInfo(i)[1].decode() == "hopper"):
|
||||
@@ -52,10 +49,8 @@ def main():
|
||||
score = 0
|
||||
restart_delay = 0
|
||||
#disable rendering during reset, makes loading much faster
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
obs = env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
|
||||
|
||||
while 1:
|
||||
time.sleep(0.001)
|
||||
a = pi.act(obs)
|
||||
|
||||
@@ -30,13 +30,9 @@ class SmallReactivePolicy:
|
||||
|
||||
def main():
|
||||
env = gym.make("HumanoidBulletEnv-v0")
|
||||
|
||||
cid = p.connect(p.GUI)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)
|
||||
env.render(mode="human")
|
||||
pi = SmallReactivePolicy(env.observation_space, env.action_space)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
torsoId = -1
|
||||
for i in range (p.getNumBodies()):
|
||||
print(p.getBodyInfo(i))
|
||||
@@ -47,10 +43,8 @@ def main():
|
||||
frame = 0
|
||||
score = 0
|
||||
restart_delay = 0
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
obs = env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
|
||||
|
||||
while 1:
|
||||
time.sleep(0.001)
|
||||
a = pi.act(obs)
|
||||
|
||||
@@ -29,9 +29,8 @@ class SmallReactivePolicy:
|
||||
|
||||
def main():
|
||||
env = gym.make("InvertedDoublePendulumBulletEnv-v0")
|
||||
|
||||
cid = p.connect(p.GUI)
|
||||
|
||||
env.render(mode="human")
|
||||
|
||||
pi = SmallReactivePolicy(env.observation_space, env.action_space)
|
||||
|
||||
while 1:
|
||||
|
||||
@@ -30,8 +30,7 @@ class SmallReactivePolicy:
|
||||
def main():
|
||||
print("create env")
|
||||
env = gym.make("InvertedPendulumBulletEnv-v0")
|
||||
print("connecting")
|
||||
cid = p.connect(p.GUI)
|
||||
env.render(mode="human")
|
||||
pi = SmallReactivePolicy(env.observation_space, env.action_space)
|
||||
|
||||
while 1:
|
||||
|
||||
@@ -29,9 +29,8 @@ class SmallReactivePolicy:
|
||||
|
||||
def main():
|
||||
env = gym.make("InvertedPendulumSwingupBulletEnv-v0")
|
||||
|
||||
cid = p.connect(p.GUI)
|
||||
|
||||
env.render(mode="human")
|
||||
|
||||
pi = SmallReactivePolicy(env.observation_space, env.action_space)
|
||||
|
||||
while 1:
|
||||
|
||||
@@ -29,15 +29,10 @@ class SmallReactivePolicy:
|
||||
|
||||
def main():
|
||||
env = gym.make("Walker2DBulletEnv-v0")
|
||||
|
||||
cid = p.connect(p.GUI)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)
|
||||
env.render(mode="human")
|
||||
pi = SmallReactivePolicy(env.observation_space, env.action_space)
|
||||
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
|
||||
env.reset()
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
|
||||
torsoId = -1
|
||||
for i in range (p.getNumBodies()):
|
||||
print(p.getBodyInfo(i))
|
||||
|
||||
Reference in New Issue
Block a user