样例程序14:MM_S14_Vis_GetUserData
程序解读
以下为MM_S14_Vis_GetUserData样例程序的代码及相关解释说明。
与MM_S1_Vis_Basic样例相比,本样例仅修改了如下加粗部分的代码。因此,下文不再重复解释与MM_S1_Vis_Basic样例相同部分的代码(详情请参考MM_S1_Vis_Basic样例说明)。 |
1: !-------------------------------- ;
2: !FUNCTION: trigger Mech-Vision ;
3: !project and get vision result ;
4: !and custom data using ;
5: !command 110 ;
6: !Mech-Mind, 2023-12-25 ;
7: !-------------------------------- ;
8: ;
9: !set current uframe NO. to 0 ;
10: UFRAME_NUM=0 ;
11: !set current tool NO. to 1 ;
12: UTOOL_NUM=1 ;
13: !move to robot home position ;
14:J P[1] 100% FINE ;
15: !initialize communication ;
16: !parameters(initialization is ;
17: !required only once) ;
18: CALL MM_INIT_SKT('8','127.0.0.1',50000,5) ;
19: !move to image-capturing position ;
20:L P[2] 1000mm/sec FINE ;
21: !trigger NO.1 Mech-Vision project ;
22: CALL MM_START_VIS(1,0,2,10) ;
23: !get vision result from NO.1 ;
24: !Mech-Vision project ;
25: CALL MM_GET_DY_DT(1,51,53) ;
26: !check whether vision result has ;
27: !been got from Mech-Vision ;
28: !successfully ;
29: IF R[53]<>1100,JMP LBL[99] ;
30: !save first vision point data to ;
31: !local variables ;
32: CALL MM_GET_DYPOS(1,60,70,90) ;
33: !save received custom data ;
34: R[10]=R[90] ;
35: R[11]=R[91] ;
36: R[12]=R[92] ;
37: !move to intermediate waypoint ;
38: !of picking ;
39:J P[3] 50% CNT100 ;
40: !move to approach waypoint ;
41: !of picking ;
42:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1] ;
43: !move to picking waypoint ;
44:L PR[60] 300mm/sec FINE ;
45: !add object grasping logic here, ;
46: !such as "DO[1]=ON" ;
47: PAUSE ;
48: !move to departure waypoint ;
49: !of picking ;
50:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1] ;
51: !move to intermediate waypoint ;
52: !of placing ;
53:J P[4] 50% CNT100 ;
54: !move to approach waypoint ;
55: !of placing ;
56:L P[5] 1000mm/sec FINE Tool_Offset,PR[2] ;
57: !move to placing waypoint ;
58:L P[5] 300mm/sec FINE ;
59: !add object releasing logic here, ;
60: !such as "DO[1]=OFF" ;
61: PAUSE ;
62: !move to departure waypoint ;
63: !of placing ;
64:L P[5] 1000mm/sec FINE Tool_Offset,PR[2] ;
65: !move back to robot home position ;
66:J P[1] 100% FINE ;
67: END ;
68: ;
69: LBL[99:vision error] ;
70: !add error handling logic here ;
71: !according to different ;
72: !error codes ;
73: !e.g.: status=1003 means no ;
74: !point cloud in ROI ;
75: !e.g.: status=1002 means no ;
76: !vision results ;
77: PAUSE ;
上述样例程序代码对应的流程如下图所示。
下表是对加粗代码的逻辑解读。用户单击指令名称的超链接便可查看该指令的详细说明。
流程 | 代码及说明 | ||||
---|---|---|---|---|---|
获取视觉结果(包含自定义数据) |
因此,整条指令表示机器人获取Mech-Vision工程1返回的视觉结果(其中包含自定义数据)。
|
||||
转存视觉结果(包含自定义数据) |
因此,整条指令表示将第一个视觉点的工具位姿、标签和自定义数据分别转存至指定寄存器。
上述代码表示,将视觉点(抓取点)的三个自定义数据R[90]、R[91]和R[92]分别赋值给R[10]、R[11]和R[12]。
|