5 import pinocchio
as pin
13 j0 = pin.JointModelFreeFlyer()
14 elif j0 ==
"spherical":
15 j0 = pin.JointModelSpherical()
16 elif j0 ==
"sphericalzyx":
17 j0 = pin.JointModelSphericalZYX()
19 raise ValueError(
"Unknown joint type")
21 jointCube = model.addJoint(0, j0, pin.SE3.Identity(),
"joint0")
22 M = pin.SE3.Identity()
23 model.appendBodyToJoint(jointCube, pin.Inertia.FromBox(1, 0.8, 0.4, 0.2), M)
28 jointCube = model.getFrameId(
"joint0")
29 geom_model = pin.GeometryModel()
30 cube_shape = hppfcl.Box(0.8, 0.4, 0.2)
31 cube = pin.GeometryObject(
32 "cube_shape", 0, jointCube, cube_shape, pin.SE3.Identity()
34 cube.meshColor = np.array([1.0, 0.1, 0.1, 0.5])
35 geom_model.addGeometryObject(cube)
42 return model, geom_model
45 def pin_step(model, vizer, v_index_increment, dt=0.1):
46 q = pin.neutral(model)
47 v = np.zeros(model.nv)
48 v[v_index_increment] += 1.0
55 q_next = pin.integrate(model, q, v * dt)
61 if __name__ ==
"__main__":
62 list_joint0 = [
"freeflyer",
"sphericalzyx",
"spherical"]
64 for joint0_name
in list_joint0:
65 print(f
"\njoint0_name = {joint0_name}")
71 q = pin.neutral(model)
72 print(f
"neutral q configuration: {q=}")
75 vizer.initViewer(open=
True, loadModel=
True)
80 for i
in range(model.nv):