sample-model-viewer.py
Go to the documentation of this file.
1 import pinocchio as pin
2 from pinocchio.visualize import MeshcatVisualizer, GepettoVisualizer, RVizVisualizer
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  elif opt == '-r':
22  VISUALIZER = RVizVisualizer
23  else:
24  raise ValueError("Unrecognized option: " + opt)
25 
26 model = pin.buildSampleModelHumanoid()
27 visual_model = pin.buildSampleGeometryModelHumanoid(model)
28 collision_model = visual_model.copy()
29 
30 q0 = pin.neutral(model)
31 
32 if VISUALIZER:
33  viz = VISUALIZER(model, collision_model, visual_model)
34  viz.initViewer()
35  viz.loadViewerModel()
36  viz.display(q0)
37 
38  input("Enter to check a new configuration")
39 
40  q = q0.copy()
41  q[8] = pi/2
42  q[14] = pi/2
43  q[23] = -pi/2
44  q[29] = pi/2
45 
46  viz.display(q)
47 
48  input("Press enter to exit...")


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