50 free_list = st.calc_free( [0, 0, 1, 1, 0, 0] )
52 self.assertEqual(free_list[0],
False)
53 self.assertEqual(free_list[1],
False)
54 self.assertEqual(free_list[2],
True)
55 self.assertEqual(free_list[3],
True)
56 self.assertEqual(free_list[4],
False)
57 self.assertEqual(free_list[5],
False)
61 st.inflate( reshape( matrix([1, 0, 0, 0, 0, 0], float), (-1,1) ))
62 expected = numpy.matrix( [[ 1, 0, 0, 1],
65 [ 0, 0, 0, 1]], float )
70 self.assertAlmostEqual(numpy.linalg.norm(st.transform-expected), 0.0, 6)
74 p = reshape( matrix([1, 0, 0, 0, 0, 0], float), (-1,1) )
77 self.assertAlmostEqual(numpy.linalg.norm(p-result), 0.0, 6)
81 p = reshape( matrix([1, 0, 0, 0, 0, 0], float), (-1,1) )
82 config = st.params_to_config(p)
83 self.assertAlmostEqual( config[0], 1, 6)
84 self.assertAlmostEqual( config[1], 0, 6)
89 expected = numpy.matrix( [[ 1, 0, 0, 1],
92 [ 0, 0, 0, 1]], float )
97 self.assertAlmostEqual(numpy.linalg.norm(st.transform-expected), 0.0, 6)
101 expected = numpy.matrix( [[ 0,-1, 0, 0],
104 [ 0, 0, 0, 1]], float )
108 self.assertAlmostEqual(numpy.linalg.norm(st.transform-expected), 0.0, 6)
112 expected = numpy.matrix( [[ 0, 0, 1, 0],
115 [ 0, 0, 0, 1]], float )
119 self.assertAlmostEqual(numpy.linalg.norm(st.transform-expected), 0.0, 6)
123 expected = numpy.matrix( [[ 1, 0, 0, 0],
126 [ 0, 0, 0, 1]], float )
130 self.assertAlmostEqual(numpy.linalg.norm(st.transform-expected), 0.0, 6)
134 self.assertEqual(st.get_length(), 6)
137 sample_nums = range(1,6)
138 dir_name = os.path.dirname(os.path.realpath(__file__))
139 params_filenames = [os.path.join(dir_name,
'data',
'single_transform_data',
'params_%02u.txt' % n)
for n
in sample_nums]
140 transform_filenames = [os.path.join(dir_name,
'data',
'single_transform_data',
'transform_%02u.txt' % n)
for n
in sample_nums]
142 for params_filename, transform_filename
in zip(params_filenames, transform_filenames):
143 f_params = open(params_filename)
144 f_transforms = open(transform_filename)
145 param_elems = [float(x)
for x
in f_params.read().split()]
146 transform_elems = [float(x)
for x
in f_transforms.read().split()]
149 expected_result = numpy.matrix(transform_elems)
150 expected_result.shape = 4,4
152 self.assertAlmostEqual(numpy.linalg.norm(st.transform-expected_result), 0.0, 4,
"Failed on %s" % params_filename)
155 rpy_init = (1, 0.5, 0.7)
158 self.assertAlmostEqual(rpy_init[i], rpy[i])
160 if __name__ ==
'__main__':
162 rostest.unitrun(
'pr2_calibration_estimation',
'test_SingleTransform', TestSingleTransform, coverage_packages=[
'pr2_calibration_estimation.single_transform'])