def compute_calibration(self):
"""
Computes the calibration through the ViSP service and returns it.
:rtype: easy_handeye.handeye_calibration.HandeyeCalibration
"""
if len(self.samples) < HandeyeCalibrator.MIN_SAMPLES:
rospy.logwarn("{} more samples needed! Not computing the calibration".format(
HandeyeCalibrator.MIN_SAMPLES - len(self.samples)))
return
# Update data
hand_world_samples, camera_marker_samples = self.get_visp_samples()
if len(hand_world_samples.transforms) != len(camera_marker_samples.transforms):
rospy.logerr("Different numbers of hand-world and camera-marker samples!")
raise AssertionError
rospy.loginfo("Computing from %g poses..." % len(self.samples))
try:
result = self.calibrate(camera_marker_samples, hand_world_samples)
rospy.loginfo("Computed calibration: {}".format(str(result)))
transl = result.effector_camera.translation
rot = result.effector_camera.rotation
result_tuple = ((transl.x, transl.y, transl.z),
(rot.x, rot.y, rot.z, rot.w))
ret = HandeyeCalibration(self.eye_on_hand,
self.robot_base_frame,
self.robot_effector_frame,
self.tracking_base_frame,
result_tuple)
return ret
except rospy.ServiceException as ex:
rospy.logerr("Calibration failed: " + str(ex))
return None
评论列表
文章目录