gepetto-viewer.py
Go to the documentation of this file.
1 # NOTE: this example needs gepetto-gui to be installed
2 # usage: launch gepetto-gui and then run this test
3 
4 import sys
5 from pathlib import Path
6 
7 import pinocchio as pin
8 from pinocchio.visualize import GepettoVisualizer
9 
10 # Load the URDF model.
11 # Conversion with str seems to be necessary when executing this file with ipython
12 pinocchio_model_dir = Path(__file__).parent.parent / "models"
13 
14 model_path = pinocchio_model_dir / "example-robot-data/robots"
15 mesh_dir = pinocchio_model_dir
16 urdf_filename = "talos_reduced.urdf"
17 urdf_model_path = model_path / "talos_data/robots" / urdf_filename
18 
19 model, collision_model, visual_model = pin.buildModelsFromUrdf(
20  urdf_model_path, mesh_dir, pin.JointModelFreeFlyer()
21 )
22 viz = GepettoVisualizer(model, collision_model, visual_model)
23 
24 # Initialize the viewer.
25 try:
26  viz.initViewer()
27 except ImportError as err:
28  print(
29  "Error while initializing the viewer. "
30  "It seems you should install gepetto-viewer"
31  )
32  print(err)
33  sys.exit(0)
34 
35 try:
36  viz.loadViewerModel("pinocchio")
37 except AttributeError as err:
38  print(
39  "Error while loading the viewer model. "
40  "It seems you should start gepetto-viewer"
41  )
42  print(err)
43  sys.exit(0)
44 
45 # Display a robot configuration.
46 q0 = pin.neutral(model)
47 viz.display(q0)
48 
49 # Display another robot.
50 viz2 = GepettoVisualizer(model, collision_model, visual_model)
51 viz2.initViewer(viz.viewer)
52 viz2.loadViewerModel(rootNodeName="pinocchio2")
53 q = q0.copy()
54 q[1] = 1.0
55 viz2.display(q)
pinocchio.visualize
Definition: bindings/python/pinocchio/visualize/__init__.py:1
pinocchio.visualize.gepetto_visualizer.GepettoVisualizer
Definition: gepetto_visualizer.py:18


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:09