35 import roslib; roslib.load_manifest(
'calibration_estimation')
45 from sensor_msgs.msg
import JointState, CameraInfo
61 before_chain: [transformA] 64 after_chain: [transformB] 67 before_chain: [transformA] 70 after_chain: [transformB] 72 config_dict = yaml.load(config_yaml)
82 M_robot = RobotMeasurement( target_id =
"targetA",
84 M_cam = [ CameraMeasurement(camera_id=
"camA")],
85 M_chain = [ ChainMeasurement(chain_id=
"chainA"),
86 ChainMeasurement(chain_id=
"chainB") ])
88 blocks = bundler.build_blocks(M_robot)
90 self.assertEqual( len(blocks), 1)
92 self.assertEqual( block._M_cam.camera_id,
"camA" )
93 self.assertEqual( block._M_chain.chain_id,
"chainA")
100 M_robot = RobotMeasurement( target_id =
"targetA",
102 M_cam = [ CameraMeasurement(camera_id=
"camB")],
103 M_chain = [ ChainMeasurement(chain_id=
"chainA")] )
105 blocks = bundler.build_blocks(M_robot)
107 self.assertEqual( len(blocks), 0)
110 from calibration_estimation.robot_params
import RobotParams
114 config = yaml.load(
''' 117 before_chain: [transformA] 120 after_chain: [transformB] 123 robot_params = RobotParams()
124 robot_params.configure( yaml.load(
''' 128 - [ 1, 0, 0, 0, 0, 0 ] 135 - [ 2, 0, 0, 0, 0, 0 ] 147 cov: {u: 1.0, v: 1.0} 149 transformA: [0, 0, 0, 0, 0, 0] 150 transformB: [0, 0, 0, 0, 0, 0] 151 transformC: [0, 0, 0, 0, 0, 0] 152 transformD: [0, 0, 0, 0, 0, 0] 160 return config, robot_params, P
163 config, robot_params, P = self.
load()
165 camera_points = [ ImagePoint(0, 0),
169 CameraMeasurement(camera_id=
"camA",
170 cam_info=CameraInfo(P=P),
171 image_points=camera_points),
172 ChainMeasurement(chain_id=
"chainA",
173 chain_state=JointState(position=[0])) )
174 sensor.update_config(robot_params)
176 target = matrix([[1, 2],
181 cov = sensor.compute_cov(target)
182 print "\ncov:\n", cov
184 self.assertAlmostEqual(cov[0,0], 1.0, 6)
185 self.assertAlmostEqual(cov[1,0], 0.0, 6)
186 self.assertAlmostEqual(cov[2,0], 0.0, 6)
187 self.assertAlmostEqual(cov[3,0], 0.0, 6)
188 self.assertAlmostEqual(cov[1,1], 2.0, 6)
189 self.assertAlmostEqual(cov[3,3], 5.0, 6)
192 config, robot_params, P = self.
load()
194 camera_points = [ ImagePoint(0, 0),
200 CameraMeasurement(camera_id=
"camA",
201 cam_info=CameraInfo(P=P),
202 image_points=camera_points),
203 ChainMeasurement(chain_id=
"chainA",
204 chain_state=JointState(position=[0])) )
205 block.update_config(robot_params)
207 target = matrix([[1, 2, 1, 2],
212 h = block.compute_expected(target)
213 z = block.get_measurement()
214 r = block.compute_residual(target)
216 self.assertAlmostEqual(linalg.norm( h - matrix( [ [0,1,0,1],
217 [0,0,1,1] ] ).T), 0.0, 6)
218 self.assertAlmostEqual(linalg.norm( z - matrix( [ [0,1,0,1],
219 [0,0,1,1] ] ).T), 0.0, 6)
220 self.assertAlmostEqual(linalg.norm( r ), 0.0, 6)
223 sparsity = block.build_sparsity_dict()
224 self.assertEqual(sparsity[
'transforms'][
'transformA'], [1,1,1,1,1,1])
225 self.assertEqual(sparsity[
'transforms'][
'transformB'], [1,1,1,1,1,1])
226 self.assertEqual(sparsity[
'chains'][
'chainA'][
'transforms'], [[1,1,1,1,1,1]])
227 self.assertEqual(sparsity[
'rectified_cams'][
'camA'][
'baseline_shift'], 1)
229 if __name__ ==
'__main__':
231 rostest.unitrun(
'calibration_estimation',
'test_CameraChainBundler', TestCameraChainBundler, coverage_packages=[
'calibration_estimation.blocks.camera_chain'])
232 rostest.unitrun(
'calibration_estimation',
'test_CameraChainSensor', TestCameraChainSensor, coverage_packages=[
'calibration_estimation.blocks.camera_chain'])
def test_basic_no_match(self)
def test_basic_match(self)