pinocchio  3.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
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
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  '''
22  # Create the client and connect it with the display server.
23  try:
24  self.viewerviewer=gepetto.corbaserver.Client()
25  except:
26  print "Error while starting the viewer client. "
27  print "Check whether Gepetto-viewer is properly started"
29  # Open a window for displaying your model.
30  try:
31  # If the window already exists, do not do anything.
32  windowID = self.viewerviewer.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.viewerviewer.gui.createWindow (windowName)
38  # Start a new "scene" in this window, named "world", with just a floor.
39  self.viewerviewer.gui.createScene("world")
40  self.viewerviewer.gui.addSceneToWindow("world",windowID)
42  # Finally, refresh the layout to obtain your first rendering.
43  self.viewerviewer.gui.refresh()
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.viewerviewer.gui.applyConfiguration(objName,
53  pin.se3ToXYZQUATtuple(M))
54  if refresh: self.viewerviewer.gui.refresh()
def place(self, objName, M, refresh=True)
def __init__(self, windowName="pinocchio")