According to your code, the rotation reprojection error is large. Have you found this problem? The following is the function that calculates the reprojection error .
`
def compute_hand_eye_error(R_handeye, t_handeye, R_arm_list, t_arm_list, rvecs, tvecs):
"""
计算手眼标定误差(平移和旋转误差)
参数:
R_handeye: 手眼标定旋转矩阵 (3x3)
t_handeye: 手眼标定平移向量 (3x1)
R_arm_list: list of 机械臂末端旋转矩阵 (3x3 numpy arrays)
t_arm_list: list of 机械臂末端平移向量 (3x1 numpy arrays)
rvecs: list of 标定板旋转向量(相机坐标系下)
tvecs: list of 标定板平移向量(相机坐标系下)
返回:
errors: list of dict,每个dict包含 'translation_error' 和 'rotation_error' (度)
rmse_translation: 平移误差的均方根误差(单位与输入单位一致)
rmse_rotation: 旋转误差均方根误差(单位:度)
"""
errors = []
translation_errors = []
rotation_errors = []
for i in range(len(R_arm_list)):
R_arm = R_arm_list[i]
t_arm = t_arm_list[i].reshape(3, 1)
# 机械臂末端坐标系到相机坐标系的变换: T_cam_end = [R_handeye | t_handeye]
# 机械臂基座到末端的变换: T_end_base = [R_arm | t_arm]
# 标定板在相机坐标系下的真实变换由相机标定给出: T_cam_board = [R_board | t_board]
# 手眼标定关系: T_cam_end * T_end_base = T_cam_board
# 计算预测的标定板位姿 T_cam_board_pred = T_cam_end * T_end_base
R_pred = R_handeye @ R_arm
t_pred = R_handeye @ t_arm + t_handeye
# 图像标定结果转换旋转矩阵
R_board = rotation_vector_to_matrix(rvecs[i])
t_board = tvecs[i].reshape(3, 1)
# 计算平移误差(欧氏距离)
trans_err = np.linalg.norm(t_board - t_pred)
# 计算旋转误差(角度差)
R_diff = R_pred.T @ R_board
angle_err_rad = np.arccos(
np.clip((np.trace(R_diff) - 1) / 2, -1.0, 1.0))
angle_err_deg = np.degrees(angle_err_rad)
errors.append({'translation_error': trans_err,
'rotation_error': angle_err_deg})
translation_errors.append(trans_err)
rotation_errors.append(angle_err_deg)
# 计算均方根误差
rmse_translation = np.sqrt(np.mean(np.array(translation_errors)**2))
rmse_rotation = np.sqrt(np.mean(np.array(rotation_errors)**2))
return errors, rmse_translation, rmse_rotation`
内参矩阵: [[1176.34744284 0. 607.61863996] [ 0. 1186.23769984 498.52620884] [ 0. 0. 1. ]] 畸变系数: [[ 0.04484207 -0.92154605 0.00216241 -0.0050302 9.82112079]] ++++++++++相机标定完成++++++++++++++ +++++++++++手眼标定完成+++++++++++++++ 平均平移误差(RMSE): 1.364392 毫米 平均旋转误差(RMSE): 174.056 度
According to your code, the rotation reprojection error is large. Have you found this problem? The following is the function that calculates the reprojection error .
`
def compute_hand_eye_error(R_handeye, t_handeye, R_arm_list, t_arm_list, rvecs, tvecs):
"""
计算手眼标定误差(平移和旋转误差)
参数:
R_handeye: 手眼标定旋转矩阵 (3x3)
t_handeye: 手眼标定平移向量 (3x1)
R_arm_list: list of 机械臂末端旋转矩阵 (3x3 numpy arrays)
t_arm_list: list of 机械臂末端平移向量 (3x1 numpy arrays)
rvecs: list of 标定板旋转向量(相机坐标系下)
tvecs: list of 标定板平移向量(相机坐标系下)
返回:
errors: list of dict,每个dict包含 'translation_error' 和 'rotation_error' (度)
rmse_translation: 平移误差的均方根误差(单位与输入单位一致)
rmse_rotation: 旋转误差均方根误差(单位:度)
"""
errors = []
translation_errors = []
rotation_errors = []
内参矩阵: [[1176.34744284 0. 607.61863996] [ 0. 1186.23769984 498.52620884] [ 0. 0. 1. ]] 畸变系数: [[ 0.04484207 -0.92154605 0.00216241 -0.0050302 9.82112079]] ++++++++++相机标定完成++++++++++++++ +++++++++++手眼标定完成+++++++++++++++ 平均平移误差(RMSE): 1.364392 毫米 平均旋转误差(RMSE): 174.056 度