display.py
Go to the documentation of this file.
1 # Typical header of a Python script using Pinocchio
2 from pinocchio.utils import *
3 from pinocchio.explog import exp,log
4 from numpy.linalg import pinv,norm
5 import pinocchio as pin
6 import gepetto.corbaserver
7 
8 # Example of a class Display that connect to Gepetto-viewer and implement a
9 # 'place' method to set the position/rotation of a 3D visual object in a scene.
10 class Display():
11  '''
12  Class Display: Example of a class implementing a client for the Gepetto-viewer server. The main
13  method of the class is 'place', that sets the position/rotation of a 3D visual object in a scene.
14  '''
15  def __init__(self,windowName = "pinocchio" ):
16  '''
17  This function connect with the Gepetto-viewer server and open a window with the given name.
18  If the window already exists, it is kept in the current state. Otherwise, the newly-created
19  window is set up with a scene named 'world'.
20  '''
21 
22  # Create the client and connect it with the display server.
23  try:
24  self.viewer=gepetto.corbaserver.Client()
25  except:
26  print "Error while starting the viewer client. "
27  print "Check whether Gepetto-viewer is properly started"
28 
29  # Open a window for displaying your model.
30  try:
31  # If the window already exists, do not do anything.
32  windowID = self.viewer.gui.getWindowID (windowName)
33  print "Warning: window '"+windowName+"' already created."
34  print "The previously created objects will not be destroyed and do not have to be created again."
35  except:
36  # Otherwise, create the empty window.
37  windowID = self.viewer.gui.createWindow (windowName)
38  # Start a new "scene" in this window, named "world", with just a floor.
39  self.viewer.gui.createScene("world")
40  self.viewer.gui.addSceneToWindow("world",windowID)
41 
42  # Finally, refresh the layout to obtain your first rendering.
43  self.viewer.gui.refresh()
44 
45  def place(self,objName,M,refresh=True):
46  '''
47  This function places (ie changes both translation and rotation) of the object
48  names "objName" in place given by the SE3 object "M". By default, immediately refresh
49  the layout. If multiple objects have to be placed at the same time, do the refresh
50  only at the end of the list.
51  '''
52  self.viewer.gui.applyConfiguration(objName,
53  pin.se3ToXYZQUATtuple(M))
54  if refresh: self.viewer.gui.refresh()
55 
def __init__(self, windowName="pinocchio")
Definition: display.py:15
def place(self, objName, M, refresh=True)
Definition: display.py:45


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:29