2 from test_case
import PinocchioTestCase
as TestCase
3 import pinocchio
as pin
18 self.
model = pin.buildSampleModelHumanoidRandom()
21 qmax = np.full((self.
model.nq,1),np.pi)
22 self.
q = pin.randomConfiguration(self.
model,-qmax,qmax)
37 self.
model.gravity = pin.Motion.Zero()
39 self.assertLess(np.linalg.norm(ddq), self.
tolerance)
41 KKT_inverse = pin.getKKTContactDynamicMatrixInverse(self.
model,self.
data,self.
J)
44 self.assertApprox(M,np.linalg.inv(KKT_inverse)[:self.
model.nv,:self.
model.nv])
46 pin.computeAllTerms(self.
model,data_no_q,self.
q,self.
v0)
47 ddq_no_q = pin.forwardDynamics(self.
model,data_no_q,self.
tau0,self.
J,self.
gamma)
48 self.assertLess(np.linalg.norm(ddq_no_q), self.
tolerance)
50 self.assertApprox(ddq,ddq_no_q)
54 data = model.createData()
55 data_ref = model.createData()
63 pin.forwardDynamics(model,data_ref,q,v,tau,J,gamma)
64 KKT_inverse_ref = pin.getKKTContactDynamicMatrixInverse(model,data_ref,J)
66 KKT_inverse = pin.computeKKTContactDynamicMatrixInverse(model,data,q,J)
67 KKT_inverse2 = pin.computeKKTContactDynamicMatrixInverse(model,data,q,J,0.)
68 self.assertApprox(KKT_inverse,KKT_inverse_ref)
69 self.assertApprox(KKT_inverse2,KKT_inverse_ref)
74 self.
model.gravity = pin.Motion.Zero()
76 self.assertLess(np.linalg.norm(ddq), self.
tolerance)
78 pin.computeAllTerms(self.
model,data_no_q,self.
q,self.
v0)
79 ddq_no_q = pin.forwardDynamics(self.
model,data_no_q,self.
tau0,self.
J,self.
gamma,r_coeff)
80 self.assertLess(np.linalg.norm(ddq_no_q), self.
tolerance)
82 self.assertApprox(ddq,ddq_no_q)
88 ddq7 = pin.forwardDynamics(self.
model,data7,self.
q,self.
v,self.
tau,self.
J,self.
gamma)
89 ddq8 = pin.forwardDynamics(self.
model,data8,self.
q,self.
v,self.
tau,self.
J,self.
gamma,r_coeff)
90 with warnings.catch_warnings(record=
True)
as warning_list:
91 ddq9_deprecated = pin.forwardDynamics(self.
model,data9_deprecated,self.
q,self.
v,self.
tau,self.
J,self.
gamma,r_coeff,
True)
92 self.assertTrue(any(item.category == pin.DeprecatedWarning
for item
in warning_list))
93 self.assertTrue((ddq7==ddq8).all())
94 self.assertTrue((ddq7==ddq9_deprecated).all())
100 pin.computeAllTerms(self.
model,data5,self.
q,self.
v0)
101 pin.computeAllTerms(self.
model,data6,self.
q,self.
v0)
102 pin.computeAllTerms(self.
model,data9_deprecated,self.
q,self.
v0)
103 ddq5 = pin.forwardDynamics(self.
model,data5,self.
tau,self.
J,self.
gamma)
104 ddq6 = pin.forwardDynamics(self.
model,data6,self.
tau,self.
J,self.
gamma,r_coeff)
105 with warnings.catch_warnings(record=
True)
as warning_list:
106 ddq9_deprecated = pin.forwardDynamics(self.
model,data9_deprecated,self.
q,self.
v,self.
tau,self.
J,self.
gamma,r_coeff,
False)
107 self.assertTrue(any(item.category == pin.DeprecatedWarning
for item
in warning_list))
108 self.assertTrue((ddq5==ddq6).all())
109 self.assertTrue((ddq5==ddq9_deprecated).all())
114 vnext = pin.impulseDynamics(self.
model,self.
data,self.
q,self.
v0,self.
J)
115 self.assertLess(np.linalg.norm(vnext), self.
tolerance)
117 pin.crba(self.
model,data_no_q,self.
q)
118 vnext_no_q = pin.impulseDynamics(self.
model,data_no_q,self.
v0,self.
J)
119 self.assertLess(np.linalg.norm(vnext_no_q), self.
tolerance)
121 self.assertApprox(vnext, vnext_no_q)
126 vnext = pin.impulseDynamics(self.
model,self.
data,self.
q,self.
v0,self.
J,r_coeff)
127 self.assertLess(np.linalg.norm(vnext), self.
tolerance)
129 pin.crba(self.
model,data_no_q,self.
q)
130 vnext_no_q = pin.impulseDynamics(self.
model,data_no_q,self.
v0,self.
J,r_coeff)
131 self.assertLess(np.linalg.norm(vnext_no_q), self.
tolerance)
133 self.assertApprox(vnext, vnext_no_q)
138 vnext = pin.impulseDynamics(self.
model,self.
data,self.
q,self.
v0,self.
J,r_coeff,inv_damping)
139 self.assertLess(np.linalg.norm(vnext), self.
tolerance)
141 pin.crba(self.
model,data_no_q,self.
q)
142 vnext_no_q = pin.impulseDynamics(self.
model,data_no_q,self.
v0,self.
J,r_coeff,inv_damping)
143 self.assertLess(np.linalg.norm(vnext_no_q), self.
tolerance)
145 self.assertApprox(vnext, vnext_no_q)
152 vnext5 = pin.impulseDynamics(self.
model,data5,self.
q,self.
v,self.
J)
153 vnext6 = pin.impulseDynamics(self.
model,data6,self.
q,self.
v,self.
J,r_coeff)
154 vnext7 = pin.impulseDynamics(self.
model,data7,self.
q,self.
v,self.
J,r_coeff,inv_damping)
155 with warnings.catch_warnings(record=
True)
as warning_list:
156 vnext7_deprecated = pin.impulseDynamics(self.
model,data7_deprecated,self.
q,self.
v,self.
J,r_coeff,
True)
157 self.assertTrue(any(item.category == pin.DeprecatedWarning
for item
in warning_list))
158 self.assertTrue((vnext5==vnext6).all())
159 self.assertTrue((vnext5==vnext7).all())
160 self.assertTrue((vnext6==vnext7).all())
161 self.assertTrue((vnext7_deprecated==vnext7).all())
168 pin.crba(self.
model,data4,self.
q)
169 pin.crba(self.
model,data5,self.
q)
170 pin.crba(self.
model,data6,self.
q)
171 pin.crba(self.
model,data7_deprecated,self.
q)
172 vnext4 = pin.impulseDynamics(self.
model,data4,self.
v,self.
J)
173 vnext5 = pin.impulseDynamics(self.
model,data5,self.
v,self.
J,r_coeff)
174 vnext6 = pin.impulseDynamics(self.
model,data6,self.
v,self.
J,r_coeff,inv_damping)
175 with warnings.catch_warnings(record=
True)
as warning_list:
176 vnext7_deprecated = pin.impulseDynamics(self.
model,data7_deprecated,self.
q,self.
v,self.
J,r_coeff,
False)
177 self.assertTrue(any(item.category == pin.DeprecatedWarning
for item
in warning_list))
178 self.assertTrue((vnext4==vnext5).all())
179 self.assertTrue((vnext4==vnext6).all())
180 self.assertTrue((vnext5==vnext6).all())
181 self.assertTrue((vnext7_deprecated==vnext6).all())
183 if __name__ ==
'__main__':
def test_impulseDynamics_no_q(self)
JointDataTpl< Scalar, Options, JointCollectionTpl > createData(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through CreateData visitor to create a JointDataTpl.
def test_impulseDynamics_rd(self)
def test_computeKKTMatrix(self)
def test_forwardDynamics_rcoeff(self)
def test_forwardDynamics_no_q(self)
def test_impulseDynamics_q(self)
def test_impulseDynamics_r(self)
def test_impulseDynamics_default(self)
def test_forwardDynamics_default(self)
def test_forwardDynamics_q(self)