From a9455ce89176f7e9a20d2f58738c5f01def80115 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 1 Jan 2020 18:53:32 -0800 Subject: [PATCH] add 'runServer.py' script in pybullet_utils, this will run a GUI server that accepts SHARED_MEMORY connections. Handy if you run a pybullet_envs Gym environment and want to visualize it. By default, bullet_client will try to connect to a shared memory connection first. --- .../pybullet/gym/pybullet_utils/runServer.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/pybullet/gym/pybullet_utils/runServer.py diff --git a/examples/pybullet/gym/pybullet_utils/runServer.py b/examples/pybullet/gym/pybullet_utils/runServer.py new file mode 100644 index 000000000..054fe66a4 --- /dev/null +++ b/examples/pybullet/gym/pybullet_utils/runServer.py @@ -0,0 +1,18 @@ +#add parent dir to find package. Only needed for source code build, pip install doesn't need it. +import os +import inspect +currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) +parentdir = os.path.dirname(os.path.dirname(currentdir)) +os.sys.path.insert(0, parentdir) + +import pybullet_data +import pybullet as p +import time + +p.connect(p.GUI_SERVER) +p.setAdditionalSearchPath(pybullet_data.getDataPath()) + +while (1): + #this is a no-op command, to allow GUI updates on Mac OSX (main thread) + p.setPhysicsEngineParameter() + time.sleep(0.01)