Skip to content

5.工具手标定

概述

工具手标定是建立机器人末端工具坐标系的过程,通过标定可以确定工具中心点(TCP)相对于法兰中心的偏移量和旋转角度。

标定前准备

  1. 准备标定工具:尖状物体或标定锥
  2. 固定参考点:将标定锥固定在工作台上,确保标定过程中不移动
  3. 检查机器人状态:确保机器人已上电且伺服使能
  4. 选择工具手编号:确定要标定的工具手编号(1-999)

7点标定流程

步骤1:设置工具手编号

cpp
int toolNum = 3;  // 工具手编号
set_tool_hand_number(fd, toolNum);

步骤2:标定7个点

cpp
// 标定第1个点:工具手末梢垂直对准参考点
// 移动机器人到位置1
tool_hand_7_point_calibrate(fd, 1, toolNum);

// 标定第2个点:切换姿势,末端正对参考点
// 移动机器人到位置2
tool_hand_7_point_calibrate(fd, 2, toolNum);

// 标定第3个点:切换姿势,末端正对参考点
// 移动机器人到位置3
tool_hand_7_point_calibrate(fd, 3, toolNum);

// 标定第4个点:切换姿势,末端正对参考点
// 移动机器人到位置4
tool_hand_7_point_calibrate(fd, 4, toolNum);

// 标定第5个点:工具末端垂直且正对参考点(同第1点)
// 移动机器人到位置5
tool_hand_7_point_calibrate(fd, 5, toolNum);

// 标定第6个点:在第5点基础上,沿X轴负方向移动任意距离
// 移动机器人到位置6
tool_hand_7_point_calibrate(fd, 6, toolNum);

// 标定第7个点:在第6点基础上,沿Y轴正方向移动任意距离
// 移动机器人到位置7
tool_hand_7_point_calibrate(fd, 7, toolNum);

步骤3:计算标定结果

cpp
// 7个点全部标定完成后,计算标定结果
Result result = tool_hand_7_point_calibrate_caculate(fd, toolNum, 7);
if (result == 0) {
    printf("标定成功\n");
} else {
    printf("标定失败,请重新标定\n");
}

步骤4:验证标定精度

cpp
// 切换到标定的工具手
set_tool_hand_number(fd, toolNum);

// 移动机器人,使工具末梢对准标定锥
// 在直角坐标系下点动A、B、C轴,观察尖端是否对准
// 如果偏差较大,需要重新标定

20点标定流程

步骤1:设置工具手编号

cpp
int toolNum = 4;  // 工具手编号
set_tool_hand_number(fd, toolNum);

步骤2:标定20个点

cpp
// 标定20个点
for (int i = 1; i <= 20; i++) {
    // 移动机器人到标定点位
    // ...
    
    // 标记点位
    tool_hand_2_or_20_point_calibrate(fd, i);
    printf("标定第%d个点\n", i);
    
    sleep(3);  // 等待机器人移动
}

步骤3:计算标定结果

cpp
// 20个点全部标定完成后,计算标定结果
Result result = tool_hand_2_or_20_point_calibrate_caculate(fd, toolNum, false);
if (result == 0) {
    printf("20点标定成功\n");
} else {
    printf("20点标定失败\n");
}

完整代码示例

7点标定完整示例

cpp
#include <iostream>
#include "cpp_interface/nrc_api.h"

int main() {
    // 1. 连接机器人
    SOCKETFD fd = connect_robot("192.168.1.15", "6001");
    if (fd <= 0) {
        printf("连接失败\n");
        return -1;
    }
    printf("连接成功\n");
    
    // 2. 设置工具手编号
    int toolNum = 3;
    set_tool_hand_number(fd, toolNum);
    printf("设置工具手编号:%d\n", toolNum);
    
    // 3. 标定7个点
    for (int i = 1; i <= 7; i++) {
        printf("请移动机器人到第%d个标定点位置,然后按Enter...\n", i);
        std::cin.get();  // 等待用户确认
        
        Result result = tool_hand_7_point_calibrate(fd, i, toolNum);
        if (result == 0) {
            printf("标定第%d个点成功\n", i);
        } else {
            printf("标定第%d个点失败\n", i);
            return -1;
        }
    }
    
    // 4. 计算标定结果
    Result result = tool_hand_7_point_calibrate_caculate(fd, toolNum, 7);
    if (result == 0) {
        printf("标定成功!\n");
        
        // 5. 验证标定精度
        printf("请验证标定精度:\n");
        printf("  1. 切换到工具手%d\n", toolNum);
        printf("  2. 移动机器人,使工具末梢对准标定锥\n");
        printf("  3. 在直角坐标系下点动A、B、C轴\n");
        printf("  4. 观察尖端是否对准\n");
    } else {
        printf("标定失败,请重新标定\n");
    }
    
    return 0;
}

20点标定完整示例

cpp
#include <iostream>
#include "cpp_interface/nrc_api.h"

int main() {
    // 1. 连接机器人
    SOCKETFD fd = connect_robot("192.168.1.15", "6001");
    if (fd <= 0) {
        printf("连接失败\n");
        return -1;
    }
    
    // 2. 设置工具手编号
    int toolNum = 4;
    set_tool_hand_number(fd, toolNum);
    
    // 3. 标定20个点
    for (int i = 1; i <= 20; i++) {
        printf("请移动机器人到第%d个标定点位置,然后按Enter...\n", i);
        std::cin.get();
        
        Result result = tool_hand_2_or_20_point_calibrate(fd, i);
        if (result == 0) {
            printf("标定第%d个点成功\n", i);
        } else {
            printf("标定第%d个点失败\n", i);
            return -1;
        }
    }
    
    // 4. 计算标定结果
    Result result = tool_hand_2_or_20_point_calibrate_caculate(fd, toolNum, false);
    if (result == 0) {
        printf("20点标定成功!\n");
    } else {
        printf("20点标定失败\n");
    }
    
    return 0;
}

参数含义详解

工具手参数

参数含义单位说明
X工具末端相对于法兰中心,沿直角坐标系X轴方向的偏移长度mm正值表示工具末端在法兰中心X轴正方向
Y工具末端相对于法兰中心,沿直角坐标系Y轴方向的偏移长度mm正值表示工具末端在法兰中心Y轴正方向
Z工具末端相对于法兰中心,沿直角坐标系Z轴方向的偏移长度mm正值表示工具末端在法兰中心Z轴正方向
A工具末端相对于法兰中心,绕直角坐标系X轴方向旋转角度°/rad右手法则,拇指指向X轴正方向,四指弯曲方向为正
B工具末端相对于法兰中心,绕直角坐标系Y轴方向旋转角度°/rad右手法则,拇指指向Y轴正方向,四指弯曲方向为正
C工具末端相对于法兰中心,绕直角坐标系Z轴方向的旋转角度°/rad右手法则,拇指指向Z轴正方向,四指弯曲方向为正

负载参数

参数含义单位说明
payloadMass负载质量kg工具和工件的总质量
payloadInertia负载惯量0.001kgm²负载的转动惯量
payloadMassCenterX负载质心Xm负载质心相对于工具坐标系的X坐标
payloadMassCenterY负载质心Ym负载质心相对于工具坐标系的Y坐标
payloadMassCenterZ负载质心Zm负载质心相对于工具坐标系的Z坐标

验证标定精度

验证方法

  1. 切换到标定的工具手

    cpp
    set_tool_hand_number(fd, toolNum);
  2. 移动机器人,使工具末梢对准标定锥

  3. 在直角坐标系下点动 A、B、C 轴

    • 观察尖端是否对准
    • 记录偏差值(mm)
  4. 判断标定精度

    • 偏差 < 0.5mm:标定精度良好
    • 偏差 0.5-1.0mm:标定精度一般,可接受
    • 偏差 > 1.0mm:标定精度差,需要重新标定

常见问题

Q: 标定失败,计算结果大于1 A: 可能原因:

  • 标定点位置不准确
  • 标定过程中参考点移动
  • 机器人姿态不正确

解决方案:

  • 重新标定,确保参考点固定
  • 检查机器人姿态是否正确
  • 使用更精确的标定工具

Q: 标定后 A、B 轴旋转误差大 A: 可能原因:

  • 6点标定精度不够
  • 标定点分布不合理

解决方案:

  • 更换7点标定
  • 重新标定,确保标定点分布合理

Q: 标定后 C 轴旋转误差大 A: 可能原因:

  • 标定点位置不准确
  • 参考点移动

解决方案:

  • 重新标定
  • 确保参考点固定