Use pybullet_utils.bullet_client for all our BulletClient needs
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
import functools
|
||||
import inspect
|
||||
import pybullet
|
||||
|
||||
|
||||
class BulletClient(object):
|
||||
"""A wrapper for pybullet to manage different clients."""
|
||||
|
||||
def __init__(self, connection_mode=pybullet.DIRECT, options=""):
|
||||
"""Create a simulation and connect to it."""
|
||||
self._client = pybullet.connect(pybullet.SHARED_MEMORY)
|
||||
if (self._client < 0):
|
||||
print("options=", options)
|
||||
self._client = pybullet.connect(connection_mode, options=options)
|
||||
self._shapes = {}
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up connection if not already done."""
|
||||
try:
|
||||
pybullet.disconnect(physicsClientId=self._client)
|
||||
except pybullet.error:
|
||||
pass
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""Inject the client id into Bullet functions."""
|
||||
attribute = getattr(pybullet, name)
|
||||
if inspect.isbuiltin(attribute):
|
||||
attribute = functools.partial(attribute, physicsClientId=self._client)
|
||||
return attribute
|
||||
@@ -17,7 +17,7 @@ from gym import spaces
|
||||
from gym.utils import seeding
|
||||
import numpy as np
|
||||
import pybullet
|
||||
from . import bullet_client
|
||||
import pybullet_utils.bullet_client as bc
|
||||
from . import minitaur
|
||||
import pybullet_data
|
||||
from . import minitaur_env_randomizer
|
||||
@@ -150,9 +150,9 @@ class MinitaurBulletDuckEnv(gym.Env):
|
||||
self._action_repeat *= NUM_SUBSTEPS
|
||||
|
||||
if self._is_render:
|
||||
self._pybullet_client = bullet_client.BulletClient(connection_mode=pybullet.GUI)
|
||||
self._pybullet_client = bc.BulletClient(connection_mode=pybullet.GUI)
|
||||
else:
|
||||
self._pybullet_client = bullet_client.BulletClient()
|
||||
self._pybullet_client = bc.BulletClient()
|
||||
|
||||
self.seed()
|
||||
self.reset()
|
||||
|
||||
@@ -14,7 +14,7 @@ from gym import spaces
|
||||
from gym.utils import seeding
|
||||
import numpy as np
|
||||
import pybullet
|
||||
from . import bullet_client
|
||||
import pybullet_utils.bullet_client as bc
|
||||
from . import minitaur
|
||||
import os
|
||||
import pybullet_data
|
||||
@@ -145,9 +145,9 @@ class MinitaurBulletEnv(gym.Env):
|
||||
self._action_repeat *= NUM_SUBSTEPS
|
||||
|
||||
if self._is_render:
|
||||
self._pybullet_client = bullet_client.BulletClient(connection_mode=pybullet.GUI)
|
||||
self._pybullet_client = bc.BulletClient(connection_mode=pybullet.GUI)
|
||||
else:
|
||||
self._pybullet_client = bullet_client.BulletClient()
|
||||
self._pybullet_client = bc.BulletClient()
|
||||
|
||||
self.seed()
|
||||
self.reset()
|
||||
|
||||
@@ -12,7 +12,7 @@ import numpy as np
|
||||
import pybullet
|
||||
from . import racecar
|
||||
import random
|
||||
from . import bullet_client
|
||||
import pybullet_utils.bullet_client as bc
|
||||
import pybullet_data
|
||||
from pkg_resources import parse_version
|
||||
|
||||
@@ -40,9 +40,9 @@ class RacecarGymEnv(gym.Env):
|
||||
self._renders = renders
|
||||
self._isDiscrete = isDiscrete
|
||||
if self._renders:
|
||||
self._p = bullet_client.BulletClient(connection_mode=pybullet.GUI)
|
||||
self._p = bc.BulletClient(connection_mode=pybullet.GUI)
|
||||
else:
|
||||
self._p = bullet_client.BulletClient()
|
||||
self._p = bc.BulletClient()
|
||||
|
||||
self.seed()
|
||||
#self.reset()
|
||||
|
||||
@@ -10,7 +10,7 @@ from gym.utils import seeding
|
||||
import numpy as np
|
||||
import time
|
||||
import pybullet
|
||||
from . import bullet_client
|
||||
import pybullet_utils.bullet_client as bc
|
||||
from . import racecar
|
||||
import random
|
||||
import pybullet_data
|
||||
@@ -42,9 +42,9 @@ class RacecarZEDGymEnv(gym.Env):
|
||||
|
||||
self._isDiscrete = isDiscrete
|
||||
if self._renders:
|
||||
self._p = bullet_client.BulletClient(connection_mode=pybullet.GUI)
|
||||
self._p = bc.BulletClient(connection_mode=pybullet.GUI)
|
||||
else:
|
||||
self._p = bullet_client.BulletClient()
|
||||
self._p = bc.BulletClient()
|
||||
|
||||
self.seed()
|
||||
self.reset()
|
||||
|
||||
Reference in New Issue
Block a user