From 0d12f01f75af238a7a4bffa9379860c78fa84fbc Mon Sep 17 00:00:00 2001 From: jcarpent <jcarpent@laas.fr> Date: Thu, 4 Aug 2016 10:28:37 +0200 Subject: [PATCH] [Python] Update robot_wrapper to allow proper creation of scenes --- bindings/python/robot_wrapper.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/bindings/python/robot_wrapper.py b/bindings/python/robot_wrapper.py index 99d070611..8e8b8156b 100644 --- a/bindings/python/robot_wrapper.py +++ b/bindings/python/robot_wrapper.py @@ -154,29 +154,33 @@ class RobotWrapper(object): # Create the scene displaying the robot meshes in gepetto-viewer def loadDisplayModel(self, nodeName, windowName="pinocchio"): import os + print "load the model" # Open a window for displaying your model. try: # If the window already exists, do not do anything. self.windowID = self.viewer.gui.getWindowID(windowName) print "Warning: window '%s' already created. Cannot (re-)load the model." % windowName - return except: # Otherwise, create the empty window. self.windowID = self.viewer.gui.createWindow(windowName) - # Start a new "scene" in this window, named "world", with just a floor. - self.viewer.gui.createSceneWithFloor("world") - self.viewer.gui.addSceneToWindow("world", self.windowID) + # Start a new "scene" in this window, named "world", with just a floor. + gui = self.viewer.gui + scene_l = gui.getSceneList() + if "world" not in scene_l: + self.viewer.gui.createScene("world") + self.viewer.gui.addSceneToWindow("world", self.windowID) + + self.viewer.gui.createGroup(nodeName) - self.viewer.gui.createGroup(nodeName) - # iterate over visuals and create the meshes in the viewer - for visual in self.visual_model.geometryObjects : - meshName = self.viewerNodeNames(visual) - meshPath = visual.mesh_path - self.viewer.gui.addMesh(meshName, meshPath) + # iterate over visuals and create the meshes in the viewer + for visual in self.visual_model.geometryObjects : + meshName = self.viewerNodeNames(visual) + meshPath = visual.mesh_path + self.viewer.gui.addMesh(meshName, meshPath) - # Finally, refresh the layout to obtain your first rendering. - self.viewer.gui.refresh() + # Finally, refresh the layout to obtain your first rendering. + self.viewer.gui.refresh() # Display in gepetto-view the robot at configuration q, by placing all the bodies. -- GitLab