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


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