3 import pinocchio
as pin
5 from test_case
import PinocchioTestCase
as TestCase
14 self.
R, _, _ = npl.svd(self.
R)
16 self.
m = pin.SE3(self.
R, self.
p)
19 R, p, m = self.
R, self.
p, self.
m
21 [np.hstack([R, pin.skew(p).dot(R)]), np.hstack([
zero([3, 3]), R])]
23 self.assertApprox(m.action, X)
25 [np.hstack([R, np.expand_dims(p, 1)]), np.array([[0.0, 0.0, 0.0, 1.0]])]
27 self.assertApprox(m.homogeneous, M)
29 self.assertApprox((m * m2).homogeneous, m.homogeneous.dot(m2.homogeneous))
30 self.assertApprox((~m).homogeneous, npl.inv(m.homogeneous))
33 self.assertApprox(m * p, m.rotation.dot(p) + m.translation)
35 m.actInv(p), m.rotation.T.dot(p) - m.rotation.T.dot(m.translation)
43 with self.assertRaises(Exception):
45 with self.assertRaises(Exception):
47 with self.assertRaises(
54 self.assertApprox(pin.Motion.Zero().vector,
zero(6))
55 v = pin.Motion.Random()
56 self.assertApprox((m * v).vector, m.action.dot(v.vector))
57 self.assertApprox((m.actInv(v)).vector, npl.inv(m.action).dot(v.vector))
60 self.assertApprox(v.vector, np.concatenate([vv, vw]))
61 self.assertApprox((v ^ v).vector,
zero(6))
65 self.assertApprox(pin.Force.Zero().vector,
zero(6))
66 f = pin.Force.Random()
69 self.assertApprox(f.vector, np.concatenate([ff, ft]))
71 self.assertApprox((m * f).vector, npl.inv(m.action.T).dot(f.vector))
72 self.assertApprox((m.actInv(f)).vector, m.action.T.dot(f.vector))
73 v = pin.Motion.Random()
74 f = pin.Force(np.concatenate([v.vector[3:], v.vector[:3]]))
75 self.assertApprox((v ^ f).vector,
zero(6))
79 Y1 = pin.Inertia.Random()
80 Y2 = pin.Inertia.Random()
82 self.assertApprox(Y1.matrix() + Y2.matrix(), Y.matrix())
83 v = pin.Motion.Random()
84 self.assertApprox((Y * v).vector, Y.matrix().dot(v.vector))
87 m.inverse().action.T.dot(Y.matrix()).dot(m.inverse().action),
90 (m.actInv(Y)).matrix(), m.action.T.dot(Y.matrix()).dot(m.action)
94 m = pin.Motion.Random()
95 f = pin.Force.Random()
96 self.assertApprox(m ^ m, m.cross(m))
97 self.assertApprox(m ^ f, m.cross(f))
98 with self.assertRaises(TypeError):
102 if __name__ ==
"__main__":