From 3f9d0197ec040f9218cede162c01b8da1a2d8262 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 22 Dec 2020 20:13:03 -0800 Subject: [PATCH] allow to specify hostName --- examples/pybullet/gym/pybullet_utils/bullet_client.py | 7 +++++-- examples/pybullet/pybullet.c | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/pybullet/gym/pybullet_utils/bullet_client.py b/examples/pybullet/gym/pybullet_utils/bullet_client.py index 0eb09f8a2..f4995d3b5 100644 --- a/examples/pybullet/gym/pybullet_utils/bullet_client.py +++ b/examples/pybullet/gym/pybullet_utils/bullet_client.py @@ -9,7 +9,7 @@ import pybullet class BulletClient(object): """A wrapper for pybullet to manage different clients.""" - def __init__(self, connection_mode=None): + def __init__(self, connection_mode=None, hostName=None): """Creates a Bullet client and connects to a simulation. Args: @@ -27,7 +27,10 @@ class BulletClient(object): return else: connection_mode = pybullet.DIRECT - self._client = pybullet.connect(connection_mode) + if hostName is None: + self._client = pybullet.connect(connection_mode) + else: + self._client = pybullet.connect(connection_mode, hostName=hostName) def __del__(self): """Clean up connection if not already done.""" diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index 759346e36..025dd1ca7 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -403,6 +403,7 @@ static PyObject* pybullet_connectPhysicsServer(PyObject* self, PyObject* args, P if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|is", kwlist1, &method, &key, &options)) { + PyErr_Clear(); int port = -1; if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sis", kwlist2, &method, &hostName, &port, &options)) {