2 import pinocchio
as pin
5 from test_case
import PinocchioTestCase
as TestCase
13 self.
R, _, _ = npl.svd(self.
R)
15 self.
m = pin.SE3(self.
R, self.
p)
18 R, p, m = self.
R, self.
p, self.
m 19 X = np.vstack([np.hstack([R, pin.skew(p).dot(R)]), np.hstack([
zero([3, 3]), R])])
20 self.assertApprox(m.action, X)
21 M = np.vstack([np.hstack([R, np.expand_dims(p,1)]), np.array([[0., 0., 0., 1.]])])
22 self.assertApprox(m.homogeneous, M)
24 self.assertApprox((m * m2).homogeneous, m.homogeneous.dot(m2.homogeneous))
25 self.assertApprox((~m).homogeneous, npl.inv(m.homogeneous))
28 self.assertApprox(m * p, m.rotation.dot(p) + m.translation)
29 self.assertApprox(m.actInv(p), m.rotation.T.dot(p) - m.rotation.T.dot(m.translation))
35 with self.assertRaises(Exception):
37 with self.assertRaises(Exception):
39 with self.assertRaises(Exception):
44 self.assertApprox(pin.Motion.Zero().vector,
zero(6))
45 v = pin.Motion.Random()
46 self.assertApprox((m * v).vector, m.action.dot(v.vector))
47 self.assertApprox((m.actInv(v)).vector, npl.inv(m.action).dot(v.vector))
50 self.assertApprox(v.vector, np.concatenate([vv, vw]))
51 self.assertApprox((v ^ v).vector,
zero(6))
55 self.assertApprox(pin.Force.Zero().vector,
zero(6))
56 f = pin.Force.Random()
59 self.assertApprox(f.vector, np.concatenate([ff, ft]))
61 self.assertApprox((m * f).vector, npl.inv(m.action.T).dot(f.vector))
62 self.assertApprox((m.actInv(f)).vector, m.action.T.dot(f.vector))
63 v = pin.Motion.Random()
64 f = pin.Force(np.concatenate([v.vector[3:], v.vector[:3]]))
65 self.assertApprox((v ^ f).vector,
zero(6))
69 Y1 = pin.Inertia.Random()
70 Y2 = pin.Inertia.Random()
72 self.assertApprox(Y1.matrix() + Y2.matrix(), Y.matrix())
73 v = pin.Motion.Random()
74 self.assertApprox((Y * v).vector, Y.matrix().dot(v.vector))
75 self.assertApprox((m * Y).matrix(), m.inverse().action.T.dot(Y.matrix()).dot(m.inverse().action))
76 self.assertApprox((m.actInv(Y)).matrix(), m.action.T.dot(Y.matrix()).dot(m.action))
79 m = pin.Motion.Random()
80 f = pin.Force.Random()
81 self.assertApprox(m ^ m, m.cross(m))
82 self.assertApprox(m ^ f, m.cross(f))
83 with self.assertRaises(TypeError):
86 if __name__ ==
'__main__':