2 import pinocchio
as pin
6 ones =
lambda n: np.ones([n, 1]
if isinstance(n, int)
else n)
11 transform = pin.SE3.Identity()
12 self.assertTrue(np.allclose(
zero(3),transform.translation))
13 self.assertTrue(np.allclose(
eye(3), transform.rotation))
14 self.assertTrue(np.allclose(
eye(4), transform.homogeneous))
15 self.assertTrue(np.allclose(
eye(6), transform.action))
17 transform.setIdentity()
18 self.assertTrue(np.allclose(
eye(4), transform.homogeneous))
22 quat = pin.Quaternion(M.rotation)
23 M_from_quat = pin.SE3(quat,M.translation)
24 self.assertTrue(M_from_quat.isApprox(M))
27 transform = pin.SE3.Identity()
28 self.assertTrue(np.allclose(transform.translation,
zero(3)))
31 transform = pin.SE3.Identity()
32 self.assertTrue(np.allclose(transform.rotation,
eye(3)))
35 transform = pin.SE3.Identity()
36 transform.translation =
ones(3)
37 self.assertFalse(np.allclose(transform.translation,
zero(3)))
38 self.assertTrue(np.allclose(transform.translation,
ones(3)))
41 transform = pin.SE3.Identity()
42 transform.rotation =
zero([3,3])
43 self.assertFalse(np.allclose(transform.rotation,
eye(3)))
44 self.assertTrue(np.allclose(transform.rotation,
zero([3,3])))
47 amb = pin.SE3.Random()
49 self.assertTrue(np.allclose(H[0:3,0:3], amb.rotation))
50 self.assertTrue(np.allclose(H[0:3,3], amb.translation))
51 self.assertTrue(np.allclose(H[3,:], [0.,0.,0.,1.]))
53 amb_from_H = pin.SE3(H)
54 self.assertTrue(amb_from_H.isApprox(amb))
57 amb = pin.SE3.Random()
59 self.assertTrue(np.allclose(aXb[:3,:3], amb.rotation))
60 self.assertTrue(np.allclose(aXb[3:,3:], amb.rotation))
61 tblock = pin.skew(amb.translation).dot(amb.rotation)
62 self.assertTrue(np.allclose(aXb[:3,3:], tblock))
63 self.assertTrue(np.allclose(aXb[3:,:3],
zero([3,3])))
66 amb = pin.SE3.Random()
69 self.assertTrue(np.allclose(np.linalg.inv(aMb), bma.homogeneous))
72 amb = pin.SE3.Random()
73 bmc = pin.SE3.Random()
80 cMa = np.linalg.inv(aMc)
82 self.assertTrue(np.allclose(aMb.dot(bMc), aMc))
83 self.assertTrue(np.allclose(cma.homogeneous,cMa))
86 amb = pin.SE3.Random()
87 bmc = pin.SE3.Random()
94 cXa = np.linalg.inv(aXc)
96 self.assertTrue(np.allclose(aXb.dot(bXc), aXc))
97 self.assertTrue(np.allclose(cma.action,cXa))
100 amb = pin.SE3.Random()
101 aMb = amb.homogeneous
102 p_homogeneous =
rand(4)
104 p = p_homogeneous[0:3].
copy()
107 self.assertTrue(np.allclose(amb.act(p),(aMb.dot(p_homogeneous))[0:3]))
110 bMa = np.linalg.inv(aMb)
112 self.assertTrue(np.allclose(bma.act(p), (bMa.dot(p_homogeneous))[0:3]))
116 trans = M.translation
117 M.translation[2] = 1.
119 self.assertTrue(trans[2] == M.translation[2])
123 tq_vec = pin.SE3ToXYZQUAT (m)
124 tq_tup = pin.SE3ToXYZQUATtuple (m)
125 mm_vec = pin.XYZQUATToSE3 (tq_vec)
126 mm_tup = pin.XYZQUATToSE3 (tq_tup)
127 mm_lis = pin.XYZQUATToSE3 (list(tq_tup))
128 return tq_vec, tq_tup, mm_vec, mm_tup, mm_lis
130 m = pin.SE3.Identity()
131 tq_vec, tq_tup, mm_vec, mm_tup, mm_lis = compute (m)
132 self.assertTrue(np.allclose(m.homogeneous, mm_tup.homogeneous))
133 self.assertTrue(np.allclose(m.homogeneous, mm_vec.homogeneous))
134 self.assertTrue(np.allclose(m.homogeneous, mm_lis.homogeneous))
136 self.assertTrue(tq_vec[i] == 0
and tq_tup[i] == 0)
137 self.assertTrue(tq_vec[6] == 1
and tq_tup[6] == 1)
140 tq_vec, tq_tup, mm_vec, mm_tup, mm_lis = compute (m)
141 self.assertTrue (len(tq_vec) == 7)
142 self.assertTrue (len(tq_tup) == 7)
143 for a,b
in zip(tq_vec,tq_tup):
144 self.assertTrue (a==b)
145 self.assertTrue(np.allclose(m.homogeneous, mm_tup.homogeneous))
146 self.assertTrue (mm_vec == mm_tup)
147 self.assertTrue (mm_vec == mm_lis)
152 M_from_h = pin.SE3(h)
153 self.assertTrue(M == M_from_h)
156 for _
in range(100000):
157 r = pin.SE3.Random() * pin.SE3.Random()
159 self.assertTrue(s !=
'')
161 if __name__ ==
'__main__':
def test_get_rotation(self)
def test_action_matrix(self)
def test_conversions(self)
def test_several_init(self)
def test_point_action(self)
def test_constructor(self)
def test_get_translation(self)
def test_internal_product_vs_action(self)
def test_set_rotation(self)
def test_internal_product_vs_homogeneous(self)
def test_homogeneous(self)
void copy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &origin, DataTpl< Scalar, Options, JointCollectionTpl > &dest, KinematicLevel kinematic_level)
Copy part of the data from origin to dest. Template parameter can be used to select at which differen...
def test_set_translation(self)