display-shapes.py
Go to the documentation of this file.
1 import sys
2 
3 import numpy as np
4 import pinocchio as pin
5 
6 try:
7  import hppfcl
8 except ImportError:
9  print("This example requires hppfcl")
10  sys.exit(0)
11 from pinocchio.visualize import GepettoVisualizer
12 
13 model = pin.Model()
14 
15 geom_model = pin.GeometryModel()
16 geometries = [
17  hppfcl.Capsule(0.1, 0.8),
18  hppfcl.Sphere(0.5),
19  hppfcl.Box(1, 1, 1),
20  hppfcl.Cylinder(0.1, 1.0),
21  hppfcl.Cone(0.5, 1.0),
22 ]
23 for i, geom in enumerate(geometries):
24  placement = pin.SE3(np.eye(3), np.array([i, 0, 0]))
25  geom_obj = pin.GeometryObject(f"obj{i}", 0, 0, placement, geom)
26  color = np.random.uniform(0, 1, 4)
27  color[3] = 1
28  geom_obj.meshColor = color
29  geom_model.addGeometryObject(geom_obj)
30 
32  model=model,
33  collision_model=geom_model,
34  visual_model=geom_model,
35 )
36 
37 # Initialize the viewer.
38 try:
39  viz.initViewer()
40 except ImportError as error:
41  print(
42  "Error while initializing the viewer. "
43  "It seems you should install gepetto-viewer"
44  )
45  print(error)
46  sys.exit(0)
47 
48 try:
49  viz.loadViewerModel("shapes")
50 except AttributeError as error:
51  print(
52  "Error while loading the viewer model. "
53  "It seems you should start gepetto-viewer"
54  )
55  print(error)
56  sys.exit(0)
57 
58 viz.display(np.zeros(0))
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 Fri Nov 1 2024 02:41:43