Merge pull request #2472 from erwincoumans/master
fix issue in BulletClient (pybullet_utils.bullet_client) that may dis…
This commit is contained in:
@@ -21,7 +21,6 @@ class BulletClient(object):
|
||||
`pybullet.SHARED_MEMORY` connects to an existing simulation.
|
||||
"""
|
||||
self._shapes = {}
|
||||
|
||||
if connection_mode is None:
|
||||
self._client = pybullet.connect(pybullet.SHARED_MEMORY)
|
||||
if self._client >= 0:
|
||||
@@ -32,14 +31,17 @@ class BulletClient(object):
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up connection if not already done."""
|
||||
if self._client>=0:
|
||||
try:
|
||||
pybullet.disconnect(physicsClientId=self._client)
|
||||
self._client = -1
|
||||
except pybullet.error:
|
||||
pass
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""Inject the client id into Bullet functions."""
|
||||
attribute = getattr(pybullet, name)
|
||||
|
||||
if inspect.isbuiltin(attribute):
|
||||
if name not in [
|
||||
"invertTransform",
|
||||
@@ -51,4 +53,6 @@ class BulletClient(object):
|
||||
"getQuaternionFromEuler",
|
||||
]: # A temporary hack for now.
|
||||
attribute = functools.partial(attribute, physicsClientId=self._client)
|
||||
if name=="disconnect":
|
||||
self._client = -1
|
||||
return attribute
|
||||
|
||||
Reference in New Issue
Block a user