2 import pinocchio
as pin
5 from test_case
import PinocchioTestCase
as TestCase
10 R3 = pin.liegroups.R3()
11 SO3 = pin.liegroups.SO3()
13 R10 = pin.liegroups.Rn(10)
15 self.assertEqual(R3.name,
"R^3")
16 self.assertEqual(R10.name,
"R^10")
17 self.assertEqual(SO3.name,
"SO(3)")
18 self.assertEqual(R3xSO3.name, R3.name +
" x " + SO3.name)
20 self.assertEqual(R3.nq+SO3.nq, R3xSO3.nq)
21 self.assertEqual(R3.nv+SO3.nv, R3xSO3.nv)
26 for lg
in [ pin.liegroups.R3(),
29 pin.liegroups.R3() * pin.liegroups.SO3(),
32 v = np.random.rand(lg.nv)
34 q_int = lg.integrate(q,v)
36 q_interpolate = lg.interpolate(q,q_int,0.5)
38 v_diff = lg.difference(q,q_int)
39 self.assertApprox(v,v_diff)
41 J = lg.dIntegrate_dq(q, v)
43 J0 = np.random.rand(lg.nv,lg.nv)
45 J1 = lg.dIntegrate_dq(q, v, SELF, J0)
46 self.assertTrue(np.allclose(np.dot(J, J0),J1))
48 J1 = lg.dIntegrate_dq(q, v, J0, SELF)
49 self.assertTrue(np.allclose(np.dot(J0, J),J1))
51 J = lg.dIntegrate_dv(q, v)
53 J0 = np.random.rand(lg.nv,lg.nv)
55 J1 = lg.dIntegrate_dv(q, v, SELF, J0)
56 self.assertTrue(np.allclose(np.dot(J, J0),J1))
58 J1 = lg.dIntegrate_dv(q, v, J0, SELF)
59 self.assertTrue(np.allclose(np.dot(J0, J),J1))
62 for lg
in [ pin.liegroups.R3(),
65 pin.liegroups.R3() * pin.liegroups.SO3(),
70 for arg
in [ pin.ARG0, pin.ARG1 ]:
71 J = lg.dDifference(q0, q1, arg)
74 J0 = np.random.rand(lg.nv,lg.nv)
77 J1 = lg.dDifference(q0, q1, arg, SELF, J0)
78 self.assertTrue(np.allclose(np.dot(J, J0),J1))
80 J1 = lg.dDifference(q0, q1, arg, J0, SELF)
81 self.assertTrue(np.allclose(np.dot(J0, J),J1))
84 for lg
in [ pin.liegroups.R3(),
87 pin.liegroups.R3() * pin.liegroups.SO3(),
90 v = np.random.rand(lg.nv)
92 for arg
in [ pin.ARG0, pin.ARG1 ]:
94 Jint = lg.dIntegrate(q, v, arg)
95 J0 = np.random.rand(lg.nv,lg.nv)
96 Jout1 = lg.dIntegrateTransport(q, v, J0, arg)
97 Jout1_ref = Jint.dot(J0)
98 self.assertApprox(Jout1,Jout1_ref)
100 if __name__ ==
'__main__':
def test_dIntegrateTransport(self)
def test_dIntegrate(self)
def test_dDifference(self)