2 Pose a Solo-12 robot on a surface defined through a function and displayed through an
7 from pathlib
import Path
10 import pinocchio
as pin
15 pinocchio_model_dir = Path(__file__).parent.parent /
"models"
17 model_path = pinocchio_model_dir /
"example-robot-data/robots"
18 mesh_dir = pinocchio_model_dir
19 urdf_filename =
"solo12.urdf"
20 urdf_model_path = model_path /
"solo_description/robots" / urdf_filename
22 model, collision_model, visual_model = pin.buildModelsFromUrdf(
23 urdf_model_path, mesh_dir, pin.JointModelFreeFlyer()
52 vizer.initViewer(open=
True)
58 + np.cos(xy[1] ** 2 * 3) / 20
59 + np.sin(xy[1] * xy[0] * 5) / 10
63 def vizGround(viz, elevation_fn, space, name="ground", color=[1.0, 1.0, 0.6, 0.8]):
64 xg = np.arange(-2, 2, space)
66 xy_g = np.meshgrid(xg, xg)
68 elev_g = np.zeros((nx, nx))
69 elev_g[:, :] = elevation_fn(xy_g)
73 elev_g[:, :] = elev_g[::-1, :]
76 heightField = hppfcl.HeightFieldAABB(sx, sy, elev_g, np.min(elev_g))
77 pl = pin.SE3.Identity()
78 obj = pin.GeometryObject(
"ground", 0, pl, heightField)
79 obj.meshColor[:] = color
80 viz.addGeometryObject(obj)
84 vizer.loadViewerModel()
86 colorrgb = [128, 149, 255, 200]
87 colorrgb = np.array(colorrgb) / 255.0