From c1d6c6b07d2328695d48be7d1e6ee67de7b40548 Mon Sep 17 00:00:00 2001 From: Max Argus Date: Tue, 17 Jul 2018 13:50:10 +0200 Subject: [PATCH] clean test scripts --- .../eglRendererVisualShapeConverter.cpp | 2 ++ examples/pybullet/examples/rendertest.py | 28 +++++++++++----- examples/pybullet/examples/rendertest_sync.py | 33 ++++++++++--------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp b/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp index 712845712..60c248b24 100644 --- a/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp +++ b/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp @@ -143,6 +143,8 @@ struct TinyRendererVisualShapeConverterInternalData ci.m_title = "Title"; ci.m_width = m_swWidth; ci.m_height = m_swHeight; + ci.m_renderDevice = 0; + m_window->createWindow(ci); m_window->setWindowTitle(ci.m_title); b3Assert(glGetError() ==GL_NO_ERROR); diff --git a/examples/pybullet/examples/rendertest.py b/examples/pybullet/examples/rendertest.py index a4771cc16..dacc4cb04 100644 --- a/examples/pybullet/examples/rendertest.py +++ b/examples/pybullet/examples/rendertest.py @@ -19,8 +19,8 @@ pitch = -10.0 roll=0 upAxisIndex = 2 camDistance = 4 -pixelWidth = 320 -pixelHeight = 200 +pixelWidth = 84 # 320 +pixelHeight = 84 # 200 nearPlane = 0.01 farPlane = 100 fov = 60 @@ -57,7 +57,7 @@ class BulletSim(): def __exit__(self,*_,**__): pybullet.disconnect() -def test(num_runs=100, shadow=1, log=True, plot=False): +def test(num_runs=300, shadow=1, log=True, plot=False): if log: logId = pybullet.startStateLogging(pybullet.STATE_LOGGING_PROFILE_TIMINGS, "renderTimings") @@ -102,33 +102,45 @@ def test(num_runs=100, shadow=1, log=True, plot=False): #plt.show() plt.pause(0.01) - print("mean: {0} for {1} runs".format(np.mean(times), num_runs)) + mean_time = float(np.mean(times)) + print("mean: {0} for {1} runs".format(mean_time, num_runs)) print("") if log: pybullet.stopStateLogging(logId) + return mean_time if __name__ == "__main__": + res = [] + with BulletSim(pybullet.DIRECT): print("\nTesting DIRECT") - test(log=False) + mean_time = test(log=False,plot=True) + res.append(("tiny",mean_time)) with BulletSim(pybullet.DIRECT): - plugin_fn = '/home/argusm/lang/bullet3/build/lib.linux-x86_64-3.5/eglRenderer.cpython-35m-x86_64-linux-gnu.so' + plugin_fn = os.path.join(pybullet.__file__.split("bullet3")[0],"bullet3/build/lib.linux-x86_64-3.5/eglRenderer.cpython-35m-x86_64-linux-gnu.so") plugin = pybullet.loadPlugin(plugin_fn,"_tinyRendererPlugin") if plugin < 0: print("\nPlugin Failed to load!\n") sys.exit() print("\nTesting DIRECT+OpenGL") - test() + mean_time = test(log=True) + res.append(("plugin",mean_time)) with BulletSim(pybullet.GUI): print("\nTesting GUI") - test(log=False) + mean_time = test(log=False) + res.append(("egl",mean_time)) + print() + print("rendertest.py") + print("back nenv fps fps_tot") + for r in res: + print(r[0],"\t",1,round(r[1]),"\t",round(r[1])) diff --git a/examples/pybullet/examples/rendertest_sync.py b/examples/pybullet/examples/rendertest_sync.py index b2dc0b176..f7b99d20e 100644 --- a/examples/pybullet/examples/rendertest_sync.py +++ b/examples/pybullet/examples/rendertest_sync.py @@ -42,18 +42,22 @@ class TestEnv(gym.Env): self._render_width = 84 self._render_height = 84 # connecting - if self._renderer == "tiny": + if self._renderer == "tiny" or self._renderer == "plugin": optionstring='--width={} --height={}'.format(self._render_width,self._render_height) p.connect(p.DIRECT, options=optionstring) + if self._renderer == "plugin": + plugin_fn = os.path.join(p.__file__.split("bullet3")[0],"bullet3/build/lib.linux-x86_64-3.5/eglRenderer.cpython-35m-x86_64-linux-gnu.so") + plugin = p.loadPlugin(plugin_fn,"_tinyRendererPlugin") + if plugin < 0: + print("\nPlugin Failed to load! Try installing via `pip install -e .`\n") + sys.exit() + print("plugin =",plugin) + elif self._renderer == "egl": optionstring='--width={} --height={}'.format(self._render_width,self._render_height) optionstring += ' --window_backend=2 --render_device=0' p.connect(p.GUI, options=optionstring) - p.configureDebugVisualizer(p.COV_ENABLE_GUI,0) - p.configureDebugVisualizer(p.COV_ENABLE_SEGMENTATION_MARK_PREVIEW,0) - p.configureDebugVisualizer(p.COV_ENABLE_DEPTH_BUFFER_PREVIEW,0) - p.configureDebugVisualizer(p.COV_ENABLE_RGB_BUFFER_PREVIEW,0) elif self._renderer == "debug": #print("Connection: SHARED_MEMORY") @@ -62,14 +66,11 @@ class TestEnv(gym.Env): cid = p.connect(p.GUI) p.resetDebugVisualizerCamera(1.3,180,-41,[0.52,-0.2,-0.33]) - elif self._renderer == "plugin": - p.connect(p.DIRECT) - plugin_fn = os.path.join(p.__file__.split("bullet3")[0],"bullet3/build/lib.linux-x86_64-3.5/eglRenderer.cpython-35m-x86_64-linux-gnu.so") - plugin = p.loadPlugin(plugin_fn,"_tinyRendererPlugin") - if plugin < 0: - print("\nPlugin Failed to load! Try installing via `pip install -e .`\n") - sys.exit() - print("plugin =",plugin) + p.configureDebugVisualizer(p.COV_ENABLE_GUI,0) + p.configureDebugVisualizer(p.COV_ENABLE_SEGMENTATION_MARK_PREVIEW,0) + p.configureDebugVisualizer(p.COV_ENABLE_DEPTH_BUFFER_PREVIEW,0) + p.configureDebugVisualizer(p.COV_ENABLE_RGB_BUFFER_PREVIEW,0) + def __del__(self): p.disconnect() @@ -129,11 +130,13 @@ if __name__ == "__main__": env_id = "TestEnv" res = [] - for renderer in ('plugin', 'tiny', 'egl'): + for renderer in ('tiny','plugin', 'egl'): for i in (1,8): tmp = train(env_id,num_env=i,renderer=renderer) print(renderer,tmp) res.append((renderer,tmp)) print() + print("rendertest_sync.py") + print("back nenv fps fps_tot") for renderer,i in res: - print(renderer, i,i[0]*i[1]) + print(renderer,'\t', i[0],round(i[1]),'\t',round(i[0]*i[1]))