4 import pinocchio
as pin
6 from test_case
import PinocchioTestCase
as TestCase
16 self.
model = pin.buildSampleModelHumanoidRandom()
19 qmax = np.full((self.
model.nq, 1), np.pi)
20 self.
q = pin.randomConfiguration(self.
model, -qmax, qmax)
29 self.
J = pin.computeJointJacobian(
33 self.
model.getJointId(
"lleg6_joint"),
40 self.
model.gravity = pin.Motion.Zero()
41 ddq = pin.forwardDynamics(
44 self.assertLess(np.linalg.norm(ddq), self.
tolerance)
46 KKT_inverse = pin.getKKTContactDynamicMatrixInverse(
52 M, np.linalg.inv(KKT_inverse)[: self.
model.nv, : self.
model.nv]
55 pin.computeAllTerms(self.
model, data_no_q, self.
q, self.
v0)
56 ddq_no_q = pin.forwardDynamics(
59 self.assertLess(np.linalg.norm(ddq_no_q), self.
tolerance)
61 self.assertApprox(ddq, ddq_no_q)
65 data = model.createData()
66 data_ref = model.createData()
74 pin.forwardDynamics(model, data_ref, q, v, tau, J, gamma)
75 KKT_inverse_ref = pin.getKKTContactDynamicMatrixInverse(model, data_ref, J)
77 KKT_inverse = pin.computeKKTContactDynamicMatrixInverse(model, data, q, J)
78 KKT_inverse2 = pin.computeKKTContactDynamicMatrixInverse(model, data, q, J, 0.0)
79 self.assertApprox(KKT_inverse, KKT_inverse_ref)
80 self.assertApprox(KKT_inverse2, KKT_inverse_ref)
85 self.
model.gravity = pin.Motion.Zero()
86 ddq = pin.forwardDynamics(
96 self.assertLess(np.linalg.norm(ddq), self.
tolerance)
98 pin.computeAllTerms(self.
model, data_no_q, self.
q, self.
v0)
99 ddq_no_q = pin.forwardDynamics(
102 self.assertLess(np.linalg.norm(ddq_no_q), self.
tolerance)
104 self.assertApprox(ddq, ddq_no_q)
110 ddq7 = pin.forwardDynamics(
113 ddq8 = pin.forwardDynamics(
117 self.assertTrue((ddq7 == ddq8).all())
123 pin.computeAllTerms(self.
model, data5, self.
q, self.
v0)
124 pin.computeAllTerms(self.
model, data6, self.
q, self.
v0)
125 pin.computeAllTerms(self.
model, data9_deprecated, self.
q, self.
v0)
126 ddq5 = pin.forwardDynamics(self.
model, data5, self.
tau, self.
J, self.
gamma)
127 ddq6 = pin.forwardDynamics(
130 self.assertTrue((ddq5 == ddq6).all())
135 vnext = pin.impulseDynamics(self.
model, self.
data, self.
q, self.
v0, self.
J)
136 self.assertLess(np.linalg.norm(vnext), self.
tolerance)
138 pin.crba(self.
model, data_no_q, self.
q)
139 vnext_no_q = pin.impulseDynamics(self.
model, data_no_q, self.
v0, self.
J)
140 self.assertLess(np.linalg.norm(vnext_no_q), self.
tolerance)
142 self.assertApprox(vnext, vnext_no_q)
147 vnext = pin.impulseDynamics(
150 self.assertLess(np.linalg.norm(vnext), self.
tolerance)
152 pin.crba(self.
model, data_no_q, self.
q)
153 vnext_no_q = pin.impulseDynamics(
154 self.
model, data_no_q, self.
v0, self.
J, r_coeff
156 self.assertLess(np.linalg.norm(vnext_no_q), self.
tolerance)
158 self.assertApprox(vnext, vnext_no_q)
163 vnext = pin.impulseDynamics(
164 self.
model, self.
data, self.
q, self.
v0, self.
J, r_coeff, inv_damping
166 self.assertLess(np.linalg.norm(vnext), self.
tolerance)
168 pin.crba(self.
model, data_no_q, self.
q)
169 vnext_no_q = pin.impulseDynamics(
170 self.
model, data_no_q, self.
v0, self.
J, r_coeff, inv_damping
172 self.assertLess(np.linalg.norm(vnext_no_q), self.
tolerance)
174 self.assertApprox(vnext, vnext_no_q)
181 vnext5 = pin.impulseDynamics(self.
model, data5, self.
q, self.
v, self.
J)
182 vnext6 = pin.impulseDynamics(self.
model, data6, self.
q, self.
v, self.
J, r_coeff)
183 vnext7 = pin.impulseDynamics(
184 self.
model, data7, self.
q, self.
v, self.
J, r_coeff, inv_damping
186 self.assertTrue((vnext5 == vnext6).all())
187 self.assertTrue((vnext5 == vnext7).all())
188 self.assertTrue((vnext6 == vnext7).all())
195 pin.crba(self.
model, data4, self.
q)
196 pin.crba(self.
model, data5, self.
q)
197 pin.crba(self.
model, data6, self.
q)
198 pin.crba(self.
model, data7_deprecated, self.
q)
199 vnext4 = pin.impulseDynamics(self.
model, data4, self.
v, self.
J)
200 vnext5 = pin.impulseDynamics(self.
model, data5, self.
v, self.
J, r_coeff)
201 vnext6 = pin.impulseDynamics(
202 self.
model, data6, self.
v, self.
J, r_coeff, inv_damping
205 self.assertTrue((vnext4 == vnext5).all())
206 self.assertTrue((vnext4 == vnext6).all())
207 self.assertTrue((vnext5 == vnext6).all())
210 if __name__ ==
"__main__":