2 from pathlib
import Path
5 import pinocchio
as pin
6 from test_case
import PinocchioTestCase
as TestCase
9 @unittest.skipUnless(pin.WITH_URDFDOM,
"Needs URDFDOM")
21 self.
model = pin.buildModelFromUrdf(
25 self.
q0 = self.
model.referenceConfigurations[
"half_sitting"]
30 feet_name = [
"left_sole_link",
"right_sole_link"]
31 frame_ids = [model.getFrameId(frame_name)
for frame_name
in feet_name]
34 v = np.zeros(model.nv)
35 a = np.zeros(model.nv)
36 data = model.createData()
38 contact_models_list = []
39 contact_datas_list = []
42 contact_models_vec = pin.StdVec_RigidConstraintModel()
43 contact_datas_vec = pin.StdVec_RigidConstraintData()
44 cones_vec = pin.StdVec_CoulombFrictionCone()
46 for frame_id
in frame_ids:
47 frame = model.frames[frame_id]
48 contact_model = pin.RigidConstraintModel(
49 pin.ContactType.CONTACT_3D, model, frame.parentJoint, frame.placement
52 contact_models_list.append(contact_model)
53 contact_datas_list.append(contact_model.createData())
54 cones_list.append(pin.CoulombFrictionCone(0.4))
56 contact_models_vec.append(contact_model)
57 contact_datas_vec.append(contact_model.createData())
58 cones_vec.append(pin.CoulombFrictionCone(0.4))
61 for m
in contact_models_list:
62 constraint_dim += m.size()
65 R = np.zeros(constraint_dim)
66 constraint_correction = np.zeros(constraint_dim)
67 lambda_guess = np.zeros(constraint_dim)
68 prox_settings = pin.ProximalSettings(1e-12, 1e-6, 1)
72 tau1 = pin.contactInverseDynamics(
83 constraint_correction,
89 tau2 = pin.contactInverseDynamics(
100 constraint_correction,
106 tau3 = pin.contactInverseDynamics(
117 constraint_correction,
121 self.assertApprox(tau1, tau2)
122 self.assertApprox(tau1, tau3)
125 if __name__ ==
"__main__":