* This example explains how to perform the hand-eye calibration for
* a SCARA robot. In this case, the camera is attached to the robot tool
* and the calibration object is stationary with respect to the robot. *
* Provide the description file of the calibration plate and the
* camera parameters of the previously calibrated camera
*提供校准板的描述文件和以前校准的摄像机的摄像机参数CalibObjDescr := 'calibrate_hand_eye_scara_setup_01_calplate.cpd' CameraParam := [0.004938,-10379.136,4.65138e-006,4.65e-006,617.294,534.687 ,1280,1024]
dev_close_window ()
dev_open_window_fit_size (0, 0, 1280, 1024, 640, -1, WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_update_off ()
*
* Acquire calibration images and corresponding robot poses
* 获取校准图像和相应的机器人姿势
* Create a new calibration model
create_calib_data ('hand_eye_scara_moving_cam', 1, 1, CalibDataID)
create_calib_data ('hand_eye_scara_moving_cam', 1, 1, CalibDataID1)
* Set the camera parameters in the calibration model
set_calib_data_cam_param (CalibDataID1, 0, 'area_scan_division', CameraParam)
set_calib_data_cam_param (CalibDataID, 0, 'area_scan_division', CameraParam)
* Set the calibration plate in the calibration model
*在校准模型中设置校准板
set_calib_data_calib_object (CalibDataID, 0, CalibObjDescr)
for Index := 1 to 10 by 1
* Read the calibration image
read_image (CalibImage, '3d_machine_vision/handeye/scara_moving_cam_setup_01_calib _' + Index$'02')
* Read the corresponding robot pose (pose of the tool in the * robot base coordinate system)
*读取相应的机器人姿势(机器人基座坐标系中的刀具姿态)
read_pose
('scara_moving_cam_setup_01_tool_in_base_pose_' + Index$'02' + '.dat', ToolInBasePose)
* Set the robot pose in the calibration model
set_calib_data (CalibDataID, 'tool', Index, 'tool_in_base_pose', ToolInBasePose)
* Determine the pose of the calibration plate in the camera
* coordinate system and set the pose in the calibration model
*确定相机坐标系中校准板的姿态,并在校准模型中设置姿态find_calib_object (CalibImage, CalibDataID, 0, 0, Index, [], []) * Visualize
dev_display (CalibImage)
get_calib_data_observ_pose (CalibDataID, 0, 0, Index, ObjInCameraPose)
disp_caltab (WindowHandle, CalibObjDescr, CameraParam, ObjInCameraPose, 1)
disp_message (WindowHandle, 'Calibration image ' + Index + ' of 10', 'window', 12, 12, 'black', 'true')
wait_seconds (0.2)
endfor
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
* 2. Perform the hand-eye calibration
calibrate_hand_eye (CalibDataID, Errors)
*执行手眼校准
* Get the result of the calibration, i.e., the pose of
* the robot base in the camera coordinate system
*获取校准结果,即摄像机坐标系中机器人基座的姿态
get_calib_data (CalibDataID, 'camera', 0, 'tool_in_cam_pose', ToolInCamPosePre)
* Free the calibration model
clear_calib_data (CalibDataID)
* Visualize
disp_preliminary_result (WindowHandle, ToolInCamPosePre, Errors)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
* 3. Fix the pose ambiguity
*
* When calibrating a SCARA robot, it is impossible to determine * all pose parameters unambiguously. In case of a moving
* camera, the Z translation of ObjInBasePose cannot be determined.
* Therefore, it is necessary to fix the unknown translation in
* Z by moving the robot to a pose of known height in the camera
* coordinate system. Because normally the camera does not see * the object if the tool is moved to the object, the robot is
* moved to two poses. For this, the calibration plate is placed
* at an arbitrary position. The robot is then manually moved such * that the camera can observe the calibration plate. Now, an image
* of the calibration plate is acquired and the robot pose is
* queried (-> ToolInBasePoseRef1). From the image, the pose of the
* calibration plate in the camera coordinate system can be
* determined (-> ObjInCamPoseRef1). Afterwards, the tool of the * robot is manually moved to the origin of the calibration plate
* (-> ToolInBasePoseRef2). These three poses and the result of the
* calibration (ToolInCamPosePre) can be used to fix the
* Z ambiguity by using the procedure fix_scara_ambiguity_moving_cam:
*校准SCARA机器人时,无法明确地确定所有姿态参数。在移动摄像机的情况下,不能确定ObjInBasePose的Z平移。
*因此,需要通过在机器人坐标系中将机器人移动到已知高度的姿势来固定Z中的未知翻译。因为通常情况下,
*如果将工具移动到物体上,相机不会看到物体,则机器人将移动到两个姿势。为此,校准板被放置在任意位置。
*然后手动移动机器人,使得相机可以观察校准板。现在,获取校
准板的图像,
*并查询机器人姿势(- > ToolInBasePoseRef1)。从图像中可以确定摄像机坐标系中校准板的姿态
*(- > ObjInCamPoseRef1)。然后,将机器人的工具手动移动到校准板的原点
*(- > ToolInBasePoseRef2)。这三个姿势和校准结果(ToolInCamPosePre)
*可用于通过使用过程fix_scara_ambiguity_moving_cam来修复Z 模糊性:
read_image (ImageRef1, '3d_machine_vision/handeye/scara_moving_cam_setup_01_calib _ref_1')
get_calib_plate_pose (ImageRef1, CameraParam, CalibObjDescr, ObjInCamPoseRef1)
手眼read_pose
('scara_moving_cam_setup_01_tool_in_base_pose_ref_1.dat', ToolInBasePoseRef1)
read_pose
('scara_moving_cam_setup_01_tool_in_base_pose_ref_2.dat', ToolInBasePoseRef2)
fix_scara_ambiguity_moving_cam (ToolInCamPosePre, ObjInCamPoseRef1, ToolInBasePoseRef1, ToolInBasePoseRef2, ZCorrection)
set_origin_pose (ToolInCamPosePre, 0, 0, ZCorrection,
发布评论