实现抓放
在本教程中,你将先了解本案例实现的抓取和放置流程、然后了解如何完成抓取和放置流程配置。
通信方案说明
在上述流程中,“机器人触发相机拍照并获取抓取点”需要机器人与视觉系统使用标准接口通信方式,并且标准接口与视觉系统的配合方式为“使用Mech-Vision获取视觉结果”。
使用该配合方式时,你需要编写机器人程序。请参考“抓取和放置流程配置”完成机器人程序的编写。
抓取和放置流程配置
要实现抓取和放置逻辑流程,需要依次完成如下配置:
配置机器人参数和编写机器人程序
安川标准接口样例程序MM_S1_Vis_Basic可以基本满足本案例所需要的功能。你可以在样例程序基础上进行修改。关于样例程序MM_S1_Vis_Basic的详细解释,请参考样例程序解读。
基于样例程序,请在机器人端完成如下操作:
-
示教Home点(初始位)。
将机器人移动到示教的初始位。初始位应远离待抓取物体及周边设备,且不遮挡相机视野。完成后,记录此时的机器人位姿到变量C00000。
-
指定工控机IP地址。将MM_Init_Socket指令对应的IP地址和端口更新为工控机IP地址和端口。
修改前 修改后(示例) 'initialize communication 'parameters (initialization is 'required only once) CALL JOB:MM_INIT_SOCKET ARGF"192.168.170.22;50000;1"
'initialize communication 'parameters (initialization is 'required only once) CALL JOB:MM_INIT_SOCKET ARGF"192.168.10.40;50000;1"
-
设置DO端口信号,以张开夹具。注意,DO指令应根据现场实际使用的DO端口号设置。
'open gripper DOUT OT#(14) ON DOUT OT#(15) OFF
-
示教固定的抓取点。
将机器人移动到示教的抓取点。该位置也是相机拍照位。在此位置,机器人手臂应不遮挡相机视野。完成后,记录此时的机器人位姿到变量C00001。
修改前 修改后(示例) 'move to image-capturing position MOVJ C00001 VJ=50.00 PL=0
'move to fixed position of picking MOVJ C00001 VJ=20.00 PL=0
-
设置DO端口信号,以闭合夹具抓取固定位置上的螺栓。注意,DO指令应根据现场实际使用的DO端口号设置。
'close gripper DOUT OT#(14) OFF DOUT OT#(15) ON
-
示教装配过程的过渡点。
修改前 修改后(示例) 'move to intermediate waypoint of 'picking MOVJ C00002 VJ=50.00
'move to intermediate waypoint of 'assembly MOVJ C00002 VJ=50.00
-
修改装配相关指令的注释。
修改前 修改后(示例) 'move to approach waypoint of 'picking SFTON P070 MOVL P071 V=166.6 PL=0 SFTOF 'move to picking waypoint MOVL P071 V=50.0 PL=0 ... 'move to departure waypoint of 'picking SFTON P070 MOVL P071 V=166.6 PL=0 SFTOF
'move to approach waypoint of 'assembly SFTON P070 MOVL P071 V=166.6 PL=0 SFTOF 'move to assembly waypoint MOVL P071 V=50.0 PL=0 ... 'move to departure waypoint of 'assembly SFTON P070 MOVL P071 V=166.6 PL=0 SFTOF
-
设置DO端口信号,以张开夹具放置螺栓到销孔。注意,DO指令应根据现场实际使用的DO端口号设置。
修改前 修改后(示例) 'add object grasping logic here, 'such as DOUT OT#(1) ON PAUSE
'add object releasing logic here, 'such as DOUT OT#(1) ON DOUT OT#(15) OFF DOUT OT#(14) ON PAUSE
-
删除示例程序中与放置相关的代码。
'move to intermediate waypoint of 'placing MOVJ C00003 VJ=50.00 'move to approach waypoint of 'placing MOVL C00004 V=166.6 PL=0 'move to placing waypoint MOVL C00005 V=50.0 PL=0 'add object releasing logic here, 'such as DOUT OT#(1) OFF PAUSE 'move to departure waypoint of 'placing MOVL C00006 V=166.6 PL=0
-
示教Home点。
将机器人移动到示教的Home点,并记录机器人位姿到C00003。
单步运行测试机器人装配效果
执行如下步骤测试机器人装配效果:
-
在示教器上旋转模式钥匙到PLAY进入再现模式。
-
按下示教器伺服准备键后,然后按蓝色运行按钮。
-
机器人将自动执行机器人程序,完成一个工件的抓取和放置。
请密切关注机器人移动轨迹,紧急情况及时按下急停键。
如果机器人可以成功抓取和放置工件,则说明机器人程序符合要求。
插入循环语句实现循环装配
在测试机器人可以成功完成单次装配,可以在程序中插入循环语句,实现机器人循环装配。
加入如下循环语句:
LOOP 'move to fixed position of picking MOVJ C00001 VJ=20.00 PL=0 ... MOVJ C00003 VJ=50.00 END LOOP
参考:修改后的样例程序
最终修改后的样例程序如下:
NOP
'--------------------------------
'FUNCTION: trigger Mech-Vision
'project and get vision result
'Mech-Mind, 2023-12-25
'--------------------------------
'clear I50 to I69
CLEAR I050 20
'initialize p variables
SUB P070 P070
SUB P071 P071
'set 100mm to z of P070
SETE P070 (3) 100000
'move to robot home position
MOVJ C00000 VJ=50.00
'initialize communication
'parameters (initialization is
'required only once)
CALL JOB:MM_INIT_SOCKET ARGF"192.168.10.40;50000;1"
'open gripper
DOUT OT#(14) ON
DOUT OT#(15) OFF
LOOP
'move to fixed position of picking
MOVJ C00001 VJ=20.00 PL=0
'close gripper
DOUT OT#(14) OFF
DOUT OT#(15) ON
'open socket connection
CALL JOB:MM_OPEN_SOCKET
MOVL P110 V=25.0
'trigger NO.1 Mech-Vision project
CALL JOB:MM_START_VIS ARGF"1;0;2;30"
'get vision result from NO.1
'Mech-Vision project
CALL JOB:MM_GET_VISDATA ARGF"1;51;52"
'check whether vision result has
'been got from Mech-Vision
'successfully
IFTHENEXP I052<>1100
'add error handling logic here
'according to different error
'codes
'e.g.: I052=1003 means no point
'cloud in ROI
'e.g.: I052=1002 means no
'vision result
PAUSE
ENDIF
'close socket connection
CALL JOB:MM_CLOSE_SOCKET
'save first vision point data to
'local variables
CALL JOB:MM_GET_POSE ARGF"1;71;61;62"
'move to intermediate waypoint of
'assembly
MOVJ C00002 VJ=50.00
'move to approach waypoint of
'assembly
SFTON P070
MOVL P071 V=166.6 PL=0
SFTOF
'move to assembly waypoint
MOVL P071 V=50.0 PL=0
'add object releasing logic here,
'such as DOUT OT#(1) ON
DOUT OT#(15) OFF
DOUT OT#(14) ON
PAUSE
'move to departure waypoint of
'assembly
SFTON P070
MOVL P071 V=166.6 PL=0
SFTOF
'move back to robot home position
MOVJ C00003 VJ=50.00’move to fixed position of picking
MOVJ C00001 VJ=20.00 PL=0
'close gripper
DOUT OT#(14) OFF
DOUT OT#(15) ON
'open socket connection
CALL JOB:MM_OPEN_SOCKET
MOVL P110 V=25.0
'trigger NO.1 Mech-Vision project
CALL JOB:MM_START_VIS ARGF"1;0;2;30"
'get vision result from NO.1
'Mech-Vision project
CALL JOB:MM_GET_VISDATA ARGF"1;51;52"
'check whether vision result has
'been got from Mech-Vision
'successfully
IFTHENEXP I052<>1100
'add error handling logic here
'according to different error
'codes
'e.g.: I052=1003 means no point
'cloud in ROI
'e.g.: I052=1002 means no
'vision result
PAUSE
ENDIF
'close socket connection
CALL JOB:MM_CLOSE_SOCKET
'save first vision point data to
'local variables
CALL JOB:MM_GET_POSE ARGF"1;71;61;62"
'move to intermediate waypoint of
'assembly
MOVJ C00002 VJ=50.00
'move to approach waypoint of
'assembly
SFTON P070
MOVL P071 V=166.6 PL=0
SFTOF
'move to assembly waypoint
MOVL P071 V=50.0 PL=0
'add object releasing logic here,
'such as DOUT OT#(1) ON
DOUT OT#(15) OFF
DOUT OT#(14) ON
PAUSE
'move to departure waypoint of
'assembly
SFTON P070
MOVL P071 V=166.6 PL=0
SFTOF
'move back to robot home position
MOVJ C00003 VJ=50.00
END LOOP
END
至此,你已完成了3D视觉引导机器人定位装配应用的部署。