How to check arriving some POS and then do other action?


#1

这样确定手臂运行到了所期望的位置,比如给出有一个循环一直获取是否Arrived的状态,获取Arrived状态后然后做其他动作,比如吸取物品。


#2

这个你是需要二次开发吗?还是其他的系统集成?


#3

对于队列命令,比如SetPTPCmd,其输入参数中会传入一个64位整形的指针,用于返回控制器给出该命令的索引(比如cmdIndex)。这之后,就可以使用GetQueuedCmdCurrentIndex,得到当前正在运行的命令的索引(比如currentIndex)。若currentIndex≥cmdIndex,则说明该条命令运行完成。

比如下面的一个简单的封装函数:

void CDobotDemoDlg::GotoPoint(UINT mode, float x, float y, float z, float r, bool waitEnd)
{
    PTPCmd ptpCmd;

    ptpCmd.ptpMode = mode;
    ptpCmd.x = x;
    ptpCmd.y = y;
    ptpCmd.z = z;
    ptpCmd.r = r;

    // Send the command. If failed, just resend the command
    uint64_t queuedCmdIndex;
    do {
        int result = SetPTPCmd(&ptpCmd, true, &queuedCmdIndex);
        if (result == DobotCommunicate_NoError) {
            break;
        }
    } while (1);

    // Check whether the command is finished
    do {
        if (waitEnd == false) {
            break;
        }
        uint64_t currentIndex;
        int result = GetQueuedCmdCurrentIndex(&currentIndex);
        if (result == DobotCommunicate_NoError &&
            currentIndex >= queuedCmdIndex) {
                break;
        }
    } while (1);
}

当传入参数waitEnd = true时,就是一直等待到这条命令执行完成为止。

建议下载Demo