2 import pinocchio
as pin
6 from test_case
import PinocchioTestCase
as TestCase
11 Y = pin.Inertia.Zero()
12 self.assertTrue(Y.mass == 0)
13 self.assertTrue(np.allclose(
zero(3), Y.lever))
14 self.assertTrue(np.allclose(
zero([3,3]), Y.inertia))
17 Y = pin.Inertia.Identity()
18 self.assertTrue(Y.mass == 1)
19 self.assertTrue(np.allclose(
zero(3), Y.lever))
20 self.assertTrue(np.allclose(
eye(3), Y.inertia))
24 Y = pin.Inertia.Identity()
26 self.assertFalse(Y.mass == 1)
27 self.assertFalse(np.allclose(
zero(3), Y.lever))
28 self.assertFalse(np.allclose(
eye(3), Y.inertia))
31 Y = pin.Inertia.Zero()
34 self.assertTrue(Y.mass == 0)
35 self.assertTrue(np.allclose(
zero(3), Y.lever))
36 self.assertTrue(np.allclose(
zero([3,3]), Y.inertia))
39 Y = pin.Inertia.Zero()
41 self.assertTrue(Y.mass == 1)
42 self.assertTrue(np.allclose(
zero(3), Y.lever))
43 self.assertTrue(np.allclose(
eye(3), Y.inertia))
46 Y = pin.Inertia.Zero()
48 self.assertTrue(np.allclose(Y.mass, 10))
51 Y = pin.Inertia.Zero()
54 self.assertTrue(np.allclose(Y.lever, lev))
57 Y = pin.Inertia.Zero()
59 iner = (iner + iner.T) / 2.
61 self.assertTrue(np.allclose(Y.inertia, iner))
64 Y1 = pin.Inertia.Random()
65 Y2 = pin.Inertia.Random()
67 self.assertTrue(np.allclose(Y1.matrix() + Y2.matrix(), Y.matrix()))
71 Y = pin.Inertia.Random()
72 v = pin.Motion.Random()
73 self.assertTrue(np.allclose((Y * v).vector, Y.matrix().dot(v.vector)))
74 self.assertTrue(np.allclose((m * Y).matrix(), m.inverse().action.T.dot(Y.matrix()).dot(m.inverse().action)))
75 self.assertTrue(np.allclose(m.act(Y).matrix(), m.inverse().action.T.dot(Y.matrix()).dot(m.inverse().action)))
76 self.assertTrue(np.allclose((m.actInv(Y)).matrix(), m.action.T.dot(Y.matrix()).dot(m.action)))
79 I = pin.Inertia.Random()
81 v = I.toDynamicParameters()
83 self.assertApprox(v[0], I.mass)
84 self.assertApprox(v[1:4], I.mass * I.lever)
86 I_o = I.inertia + I.mass * pin.skew(I.lever).transpose().dot(pin.skew(I.lever))
88 [[float(v[4]), float(v[5]), float(v[7])],
89 [float(v[5]), float(v[6]), float(v[8])],
90 [float(v[7]), float(v[8]), float(v[9])]
94 self.assertApprox(I_o, I_ov)
96 I2 = pin.Inertia.FromDynamicParameters(v)
97 self.assertApprox(I2, I)
100 I = pin.Inertia.Random()
101 I_array = np.array(I)
103 self.assertApprox(I_array,I.matrix())
105 if __name__ ==
'__main__':
def test_se3_action(self)
def test_dynamic_parameters(self)
def test_zero_getters(self)
def test_identity_getters(self)
def test_internal_sums(self)
def test_setIdentity(self)
def test_set_inertia(self)