样例程序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',30000,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,53) ;
23: !check whether vision project has ;
24: !been triggered successfully ;
25: IF (R[53]<>1102),JMP LBL[99] ;
26: !get vision result from NO.1 ;
27: !Mech-Vision project ;
28: CALL MM_GET_DY_DT(1,51,53) ;
29: !check whether vision result has ;
30: !been got from Mech-Vision ;
31: !successfully ;
32: IF R[53]<>1100,JMP LBL[99] ;
33: !save first vision point data to ;
34: !local variables ;
35: CALL MM_GET_DYPOS(1,60,70,90) ;
36: !save received custom data ;
37: R[10]=R[90] ;
38: R[11]=R[91] ;
39: R[12]=R[92] ;
40: !move to intermediate waypoint ;
41: !of picking ;
42:J P[3] 50% CNT100 ;
43: !move to approach waypoint ;
44: !of picking ;
45:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1] ;
46: !move to picking waypoint ;
47:L PR[60] 300mm/sec FINE ;
48: !add object grasping logic here, ;
49: !such as "DO[1]=ON" ;
50: PAUSE ;
51: !move to departure waypoint ;
52: !of picking ;
53:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1] ;
54: !move to intermediate waypoint ;
55: !of placing ;
56:J P[4] 50% CNT100 ;
57: !move to approach waypoint ;
58: !of placing ;
59:L P[5] 1000mm/sec FINE Tool_Offset,PR[2] ;
60: !move to placing waypoint ;
61:L P[5] 300mm/sec FINE ;
62: !add object releasing logic here, ;
63: !such as "DO[1]=OFF" ;
64: PAUSE ;
65: !move to departure waypoint ;
66: !of placing ;
67:L P[5] 1000mm/sec FINE Tool_Offset,PR[2] ;
68: !move back to robot home position ;
69:J P[1] 100% FINE ;
70: END ;
71: ;
72: LBL[99:vision error] ;
73: !add error handling logic here ;
74: !according to different ;
75: !error codes ;
76: !e.g.: status=1003 means no ;
77: !point cloud in ROI ;
78: !e.g.: status=1002 means no ;
79: !vision results ;
80: !e.g.: status=3099 means ;
81: !failed to open socket ;
82: PAUSE ;
上述样例程序代码对应的流程如下图所示。
下表是对加粗代码的逻辑解读。用户单击指令名称的超链接便可查看该指令的详细说明。
| 流程 | 代码及说明 | ||||
|---|---|---|---|---|---|
获取视觉结果(包含自定义数据) |
因此,整条指令表示机器人获取Mech-Vision工程1返回的视觉结果(其中包含自定义数据)。
|
||||
转存视觉结果(包含自定义数据) |
因此,整条指令表示将第一个视觉点的工具位姿、标签和自定义数据分别转存至指定寄存器。
上述代码表示,将视觉点(抓取点)的三个自定义数据R[90]、R[91]和R[92]分别赋值给R[10]、R[11]和R[12]。
|