Skip to content

Commit ba4888f

Browse files
committed
[Tests] Update details
1 parent af403dc commit ba4888f

File tree

5 files changed

+71
-88
lines changed

5 files changed

+71
-88
lines changed

tests/control/test_control_pd.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ BOOST_AUTO_TEST_CASE(control_pd) {
5050
{
5151
boost::test_tools::output_test_stream output;
5252
aControlPD->controlSOUT.get(output);
53-
BOOST_CHECK(output.is_equal(" 20.15\n 42.28\n 66.39\n 92.48\n120.55\n"));
53+
BOOST_CHECK(output.is_equal("20.15 42.28 66.39 92.48 120.55"));
5454
}
5555
{
5656
boost::test_tools::output_test_stream output;
5757
aControlPD->positionErrorSOUT.get(output);
58-
BOOST_CHECK(output.is_equal(" 2\n2.1\n2.2\n2.3\n2.4\n"));
58+
BOOST_CHECK(output.is_equal("2 2.1 2.2 2.3 2.4"));
5959
}
6060
{
6161
boost::test_tools::output_test_stream output;
6262
aControlPD->velocityErrorSOUT.get(output);
63-
BOOST_CHECK(output.is_equal("1.5\n1.4\n1.3\n1.2\n1.1\n"));
63+
BOOST_CHECK(output.is_equal("1.5 1.4 1.3 1.2 1.1"));
6464
}
6565
}

tests/filters/test_filter_differentiator.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ BOOST_AUTO_TEST_CASE(test_filter_differentiator) {
6767
dynamicgraph::Vector outVec;
6868
aFilterDiff->m_x_filteredSOUT.get(output);
6969

70-
BOOST_CHECK(output.is_equal("82.5614\n"
71-
"86.5403\n"
72-
"78.5826\n"
73-
"17.9049\n"
74-
"96.4874\n"
75-
"39.7886\n"
76-
"91.5139\n"
77-
"98.4769\n"
78-
"56.6988\n"
79-
"29.8415\n"
80-
"71.6195\n"
81-
"37.7992\n"
82-
"101.461\n"
83-
"71.6195\n"
84-
"76.5931\n"
85-
"40.7834\n"));
70+
BOOST_CHECK(output.is_equal("82.5614 "
71+
"86.5403 "
72+
"78.5826 "
73+
"17.9049 "
74+
"96.4874 "
75+
"39.7886 "
76+
"91.5139 "
77+
"98.4769 "
78+
"56.6988 "
79+
"29.8415 "
80+
"71.6195 "
81+
"37.7992 "
82+
"101.461 "
83+
"71.6195 "
84+
"76.5931 "
85+
"40.7834"));
8686
}

tests/filters/test_madgwick_ahrs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ BOOST_AUTO_TEST_CASE(test_filter_differentiator) {
5454
aFilter->m_imu_quatSOUT.get(output);
5555
aFilter->m_imu_quatSOUT.get(anoss);
5656

57-
BOOST_CHECK(output.is_equal(" 1\n"
58-
" 5.5547e-05\n"
59-
"-5.83205e-05\n"
60-
" 0.00015\n"));
57+
BOOST_CHECK(output.is_equal("1 "
58+
"5.5547e-05 "
59+
"-5.83205e-05 "
60+
"0.00015"));
6161
}

tests/python/initialize-euler.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
class OpPointModifierTest(unittest.TestCase):
1010
def test_initialize_ie(self):
1111
ent = ie.IntegratorEulerVectorDouble("ie")
12-
with self.assertRaises(dgpy.dgpyError) as cm:
12+
with self.assertRaises(RuntimeError) as cm:
1313
ent.initialize()
14-
self.assertEqual(
15-
str(cm.exception),
16-
'In SignalPtr: SIN ptr not set. (in signal <sotIntegratorAbstract(ie)::input(vector)::sin>)'
17-
)
14+
self.assertEqual(str(cm.exception), 'The numerator or the denominator is empty.')
1815

1916

2017
if __name__ == '__main__':

tests/python/op-point-modifier.py

Lines changed: 46 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,16 @@
77
import numpy as np
88
from dynamic_graph.sot.core.op_point_modifier import OpPointModifier
99

10-
gaze = tuple(((1.0, 0.0, 0.0, 0.025000000000000001), (0.0, 1.0, 0.0, 0.0),
11-
(0.0, 0.0, 1.0, 0.64800000000000002), (0.0, 0.0, 0.0, 1.0)))
10+
gaze = np.array((((1.0, 0.0, 0.0, 0.025), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.648), (0.0, 0.0, 0.0, 1.0))))
1211

13-
Jgaze = tuple(
14-
((1.0, 0.0, 0.0, 0.0, 0.64800000000000002,
15-
0.0), (0.0, 1.0, 0.0, -0.64800000000000002, 0.0,
16-
0.025000000000000001), (0.0, 0.0, 1.0, 0.0, -0.025000000000000001,
17-
0.0), (0.0, 0.0, 0.0, 1.0, 0.0, 0.0),
18-
(0.0, 0.0, 0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 1.0)))
12+
Jgaze = np.array(
13+
(((1.0, 0.0, 0.0, 0.0, 0.648, 0.0), (0.0, 1.0, 0.0, -0.648, 0.0, 0.025), (0.0, 0.0, 1.0, 0.0, -0.025, 0.0),
14+
(0.0, 0.0, 0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 1.0))))
1915

20-
I4 = ((1., 0., 0., 0.), (0., 1., 0., 0.), (0., 0., 1., 0.), (0., 0., 0., 1.))
16+
I4 = np.array(((1., 0., 0., 0.), (0., 1., 0., 0.), (0., 0., 1., 0.), (0., 0., 0., 1.)))
2117

22-
I6 = ((1., 0., 0., 0., 0., 0.), (0., 1., 0., 0., 0., 0.),
23-
(0., 0., 1., 0., 0., 0.), (0., 0., 0., 1., 0., 0.),
24-
(0., 0., 0., 0., 1., 0.), (0., 0., 0., 0., 0., 1.))
18+
I6 = np.array(((1., 0., 0., 0., 0., 0.), (0., 1., 0., 0., 0., 0.), (0., 0., 1., 0., 0., 0.), (0., 0., 0., 1., 0., 0.),
19+
(0., 0., 0., 0., 1., 0.), (0., 0., 0., 0., 0., 1.)))
2520

2621

2722
class OpPointModifierTest(unittest.TestCase):
@@ -33,17 +28,16 @@ def test_simple(self):
3328
op.position.recompute(0)
3429
op.jacobian.recompute(0)
3530

36-
self.assertEqual(op.getTransformation(), I4)
37-
self.assertEqual(op.position.value, I4)
38-
self.assertEqual(op.jacobian.value, I6)
31+
self.assertTrue((op.getTransformation() == I4).all())
32+
self.assertTrue((op.position.value == I4).all())
33+
self.assertTrue((op.jacobian.value == I6).all())
3934

4035
def test_translation(self):
4136
tx = 11.
4237
ty = 22.
4338
tz = 33.
4439

45-
T = ((1., 0., 0., tx), (0., 1., 0., ty), (0., 0., 1., tz), (0., 0., 0.,
46-
1.))
40+
T = np.array(((1., 0., 0., tx), (0., 1., 0., ty), (0., 0., 1., tz), (0., 0., 0., 1.)))
4741

4842
op = OpPointModifier('op2')
4943
op.setTransformation(T)
@@ -52,31 +46,28 @@ def test_translation(self):
5246
op.position.recompute(1)
5347
op.jacobian.recompute(1)
5448

55-
self.assertEqual(op.getTransformation(), T)
49+
self.assertTrue((op.getTransformation() == T).all())
5650

5751
# w_M_s = w_M_g * g_M_s
58-
w_M_g = np.asmatrix(gaze)
59-
g_M_s = np.asmatrix(T)
60-
w_M_s_ref = w_M_g * g_M_s
61-
w_M_s = np.asmatrix(op.position.value)
52+
w_M_g = gaze
53+
g_M_s = T
54+
w_M_s_ref = w_M_g.dot(g_M_s)
55+
w_M_s = op.position.value
6256

6357
# Check w_M_s == w_M_s_ref
64-
self.assertEqual(np.equal(w_M_s, w_M_s_ref).all(), True)
58+
self.assertTrue((w_M_s == w_M_s_ref).all())
6559

66-
twist = np.matrix([[1., 0., 0., 0., tz,
67-
-ty], [0., 1., 0., -tz, 0., tx],
68-
[0., 0., 1., ty, -tx, 0.], [0., 0., 0., 1., 0., 0.],
69-
[0., 0., 0., 0., 1., 0.], [0., 0., 0., 0., 0., 1.]])
60+
twist = np.array([[1., 0., 0., 0., tz, -ty], [0., 1., 0., -tz, 0., tx], [0., 0., 1., ty, -tx, 0.],
61+
[0., 0., 0., 1., 0., 0.], [0., 0., 0., 0., 1., 0.], [0., 0., 0., 0., 0., 1.]])
7062

71-
J = np.asmatrix(op.jacobian.value)
72-
J_ref = twist * Jgaze
63+
J = op.jacobian.value
64+
J_ref = twist.dot(Jgaze)
7365

7466
# Check w_M_s == w_M_s_ref
75-
self.assertEqual(np.equal(J, J_ref).all(), True)
67+
self.assertTrue((J == J_ref).all())
7668

7769
def test_rotation(self):
78-
T = ((0., 0., 1., 0.), (0., -1., 0., 0.), (1., 0., 0., 0.), (0., 0.,
79-
0., 1.))
70+
T = np.array(((0., 0., 1., 0.), (0., -1., 0., 0.), (1., 0., 0., 0.), (0., 0., 0., 1.)))
8071

8172
op = OpPointModifier('op3')
8273
op.setTransformation(T)
@@ -85,35 +76,32 @@ def test_rotation(self):
8576
op.position.recompute(1)
8677
op.jacobian.recompute(1)
8778

88-
self.assertEqual(op.getTransformation(), T)
79+
self.assertTrue((op.getTransformation() == T).all())
8980

9081
# w_M_s = w_M_g * g_M_s
91-
w_M_g = np.asmatrix(gaze)
92-
g_M_s = np.asmatrix(T)
93-
w_M_s_ref = w_M_g * g_M_s
94-
w_M_s = np.asmatrix(op.position.value)
82+
w_M_g = gaze
83+
g_M_s = T
84+
w_M_s_ref = w_M_g.dot(g_M_s)
85+
w_M_s = op.position.value
9586

9687
# Check w_M_s == w_M_s_ref
97-
self.assertEqual(np.equal(w_M_s, w_M_s_ref).all(), True)
88+
self.assertTrue((w_M_s == w_M_s_ref).all())
9889

99-
twist = np.matrix([[0., 0., 1., 0., 0., 0.], [0., -1., 0., 0., 0., 0.],
100-
[1., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 1.],
101-
[0., 0., 0., 0., -1., 0.], [0., 0., 0., 1., 0.,
102-
0.]])
90+
twist = np.array([[0., 0., 1., 0., 0., 0.], [0., -1., 0., 0., 0., 0.], [1., 0., 0., 0., 0., 0.],
91+
[0., 0., 0., 0., 0., 1.], [0., 0., 0., 0., -1., 0.], [0., 0., 0., 1., 0., 0.]])
10392

104-
J = np.asmatrix(op.jacobian.value)
105-
J_ref = twist * Jgaze
93+
J = op.jacobian.value
94+
J_ref = twist.dot(Jgaze)
10695

10796
# Check w_M_s == w_M_s_ref
108-
self.assertEqual(np.equal(J, J_ref).all(), True)
97+
self.assertTrue((J == J_ref).all())
10998

11099
def test_rotation_translation(self):
111100
tx = 11.
112101
ty = 22.
113102
tz = 33.
114103

115-
T = ((0., 0., 1., tx), (0., -1., 0., ty), (1., 0., 0., tz), (0., 0.,
116-
0., 1.))
104+
T = np.array(((0., 0., 1., tx), (0., -1., 0., ty), (1., 0., 0., tz), (0., 0., 0., 1.)))
117105

118106
op = OpPointModifier('op4')
119107
op.setTransformation(T)
@@ -122,27 +110,25 @@ def test_rotation_translation(self):
122110
op.position.recompute(1)
123111
op.jacobian.recompute(1)
124112

125-
self.assertEqual(op.getTransformation(), T)
113+
self.assertTrue((op.getTransformation() == T).all())
126114

127115
# w_M_s = w_M_g * g_M_s
128-
w_M_g = np.asmatrix(gaze)
129-
g_M_s = np.asmatrix(T)
130-
w_M_s_ref = w_M_g * g_M_s
131-
w_M_s = np.asmatrix(op.position.value)
116+
w_M_g = gaze
117+
g_M_s = T
118+
w_M_s_ref = w_M_g.dot(g_M_s)
119+
w_M_s = op.position.value
132120

133121
# Check w_M_s == w_M_s_ref
134-
self.assertEqual(np.equal(w_M_s, w_M_s_ref).all(), True)
122+
self.assertTrue((w_M_s == w_M_s_ref).all())
135123

136-
twist = np.matrix(
137-
[[0., 0., 1., ty, -tx, 0.], [0., -1., 0., tz, 0., -tx],
138-
[1., 0., 0., 0., tz, -ty], [0., 0., 0., 0., 0., 1.],
139-
[0., 0., 0., 0., -1., 0.], [0., 0., 0., 1., 0., 0.]])
124+
twist = np.array([[0., 0., 1., ty, -tx, 0.], [0., -1., 0., tz, 0., -tx], [1., 0., 0., 0., tz, -ty],
125+
[0., 0., 0., 0., 0., 1.], [0., 0., 0., 0., -1., 0.], [0., 0., 0., 1., 0., 0.]])
140126

141-
J = np.asmatrix(op.jacobian.value)
142-
J_ref = twist * Jgaze
127+
J = op.jacobian.value
128+
J_ref = twist.dot(Jgaze)
143129

144130
# Check w_M_s == w_M_s_ref
145-
self.assertEqual(np.equal(J, J_ref).all(), True)
131+
self.assertTrue((J == J_ref).all())
146132

147133

148134
if __name__ == '__main__':

0 commit comments

Comments
 (0)