sample-model-viewer.py
Go to the documentation of this file.
1 import pinocchio as pin
2 from pinocchio.visualize import MeshcatVisualizer, GepettoVisualizer
3 from sys import argv
4 from numpy import pi
5 
6 try:
7  # Python 2
8  input = raw_input # noqa
9 except NameError:
10  pass
11 
12 # GepettoVisualizer: -g
13 # MeshcatVisualizer: -m
14 VISUALIZER = None
15 if len(argv)>1:
16  opt = argv[1]
17  if opt == '-g':
18  VISUALIZER = GepettoVisualizer
19  elif opt == '-m':
20  VISUALIZER = MeshcatVisualizer
21  else:
22  raise ValueError("Unrecognized option: " + opt)
23 
24 model = pin.buildSampleModelHumanoid()
25 visual_model = pin.buildSampleGeometryModelHumanoid(model)
26 collision_model = visual_model.copy()
27 
28 q0 = pin.neutral(model)
29 
30 if VISUALIZER:
31  viz = VISUALIZER(model, collision_model, visual_model)
32  viz.initViewer()
33  viz.loadViewerModel()
34  viz.display(q0)
35 
36  input("Enter to check a new configuration")
37 
38  q = q0.copy()
39  q[8] = pi/2
40  q[14] = pi/2
41  q[23] = -pi/2
42  q[29] = pi/2
43 
44  viz.display(q)


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04