use SHARED_MEMORY as first connection attempt, to make visualization/OpenGL rendering easier

This commit is contained in:
Erwin Coumans
2017-09-11 09:23:14 -07:00
parent 16c58de272
commit f38b2cf14d
5 changed files with 16 additions and 8 deletions

View File

@@ -8,7 +8,9 @@ class BulletClient(object):
def __init__(self, connection_mode=pybullet.DIRECT): def __init__(self, connection_mode=pybullet.DIRECT):
"""Create a simulation and connect to it.""" """Create a simulation and connect to it."""
self._client = pybullet.connect(connection_mode) self._client = pybullet.connect(pybullet.SHARED_MEMORY)
if(self._client<0):
self._client = pybullet.connect(connection_mode)
self._shapes = {} self._shapes = {}
def __del__(self): def __del__(self):

View File

@@ -37,7 +37,9 @@ class KukaGymEnv(gym.Env):
self.terminated = 0 self.terminated = 0
self._p = p self._p = p
if self._renders: if self._renders:
p.connect(p.GUI) cid = p.connect(p.SHARED_MEMORY)
if (cid<0):
cid = p.connect(p.GUI)
p.resetDebugVisualizerCamera(1.3,180,-41,[0.52,-0.2,-0.33]) p.resetDebugVisualizerCamera(1.3,180,-41,[0.52,-0.2,-0.33])
else: else:
p.connect(p.DIRECT) p.connect(p.DIRECT)

View File

@@ -166,6 +166,9 @@ class MinitaurBulletEnv(gym.Env):
def set_env_randomizer(self, env_randomizer): def set_env_randomizer(self, env_randomizer):
self._env_randomizer = env_randomizer self._env_randomizer = env_randomizer
def configure(self, args):
self._args = args
def _reset(self): def _reset(self):
if self._hard_reset: if self._hard_reset:
self._pybullet_client.resetSimulation() self._pybullet_client.resetSimulation()

View File

@@ -39,13 +39,13 @@ class MJCFBaseBulletEnv(gym.Env):
def _reset(self): def _reset(self):
if (self.physicsClientId<0): if (self.physicsClientId<0):
if (self.isRender): self.physicsClientId = p.connect(p.SHARED_MEMORY)
self.physicsClientId = p.connect(p.SHARED_MEMORY) if (self.physicsClientId<0):
if (self.physicsClientId<0): if (self.isRender):
self.physicsClientId = p.connect(p.GUI) self.physicsClientId = p.connect(p.GUI)
else: else:
self.physicsClientId = p.connect(p.DIRECT) self.physicsClientId = p.connect(p.DIRECT)
#p.configureDebugVisualizer(p.COV_ENABLE_GUI,0) p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)
if self.scene is None: if self.scene is None:
self.scene = self.create_single_player_scene() self.scene = self.create_single_player_scene()

View File

@@ -467,6 +467,7 @@ setup(
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Topic :: Games/Entertainment :: Simulation', 'Topic :: Games/Entertainment :: Simulation',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Framework :: Robot Framework'], 'Framework :: Robot Framework'],
package_dir = { '': 'examples/pybullet/gym'}, package_dir = { '': 'examples/pybullet/gym'},
packages=[x for x in find_packages('examples/pybullet/gym')], packages=[x for x in find_packages('examples/pybullet/gym')],