样例程序4:MM_S4_Vis_ChangeModel
程序解读
以下为MM_S4_Vis_ChangeModel样例程序的代码及相关解释说明。
| 与MM_S1_Vis_Basic样例相比,本样例仅新增了切换Mech-Vision参数配方的功能(加粗部分的代码)。因此,下文不再重复解释与MM_S1_Vis_Basic样例相同部分的代码(详情请参考MM_S1_Vis_Basic样例说明)。 |
1: !-------------------------------- ;
2: !FUNCTION: trigger Mech-Vision ;
3: !project after switching recipe ;
4: !and get vision result ;
5: !Mech-Mind, 2023-12-25 ;
6: !-------------------------------- ;
7: ;
8: !set current uframe NO. to 0 ;
9: UFRAME_NUM=0 ;
10: !set current tool NO. to 1 ;
11: UTOOL_NUM=1 ;
12: !move to robot home position ;
13:J P[1] 100% FINE ;
14: !initialize communication ;
15: !parameters(initialization is ;
16: !required only once) ;
17: CALL MM_INIT_SKT('8','127.0.0.1',30000,5) ;
18: !move to image-capturing position ;
19:L P[2] 1000mm/sec FINE ;
20: !switch recipe of NO.1 ;
21: !Mech-Vision project, ;
22: !"MM_SET_MOD(Proj_num,Model_num,status)" ;
23: CALL MM_SET_MOD(1,1,53) ;
24: !check whether vision recipe has ;
25: !been switched successfully ;
26: IF (R[53]<>1107),JMP LBL[99] ;
27: !trigger NO.1 Mech-Vision project ;
28: CALL MM_START_VIS(1,0,2,10) ;
28: !get vision result from NO.1 ;
29: !Mech-Vision project ;
30: CALL MM_GET_VIS(1,51,53) ;
31: !check whether vision result has ;
32: !been got from Mech-Vision ;
33: !successfully ;
34: IF R[53]<>1100,JMP LBL[99] ;
35: !save first vision point data to ;
36: !local variables ;
37: CALL MM_GET_POS(1,60,70,80) ;
38: !move to intermediate waypoint ;
39: !of picking ;
40:J P[3] 50% CNT100 ;
41: !move to approach waypoint ;
42: !of picking ;
43:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1] ;
44: !move to picking waypoint ;
45:L PR[60] 300mm/sec FINE ;
46: !add object grasping logic here, ;
47: !such as "DO[1]=ON" ;
48: PAUSE ;
49: !move to departure waypoint ;
50: !of picking ;
51:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1] ;
52: !move to intermediate waypoint ;
53: !of placing ;
54:J P[4] 50% CNT100 ;
55: !move to approach waypoint ;
56: !of placing ;
57:L P[5] 1000mm/sec FINE Tool_Offset,PR[2] ;
58: !move to placing waypoint ;
59:L P[5] 300mm/sec FINE ;
60: !add object releasing logic here, ;
61: !such as "DO[1]=OFF" ;
62: PAUSE ;
63: !move to departure waypoint ;
64: !of placing ;
65:L P[5] 1000mm/sec FINE Tool_Offset,PR[2] ;
66: !move back to robot home position ;
67:J P[1] 100% FINE ;
68: END ;
69: ;
70: LBL[99:vision error] ;
71: !add error handling logic here ;
72: !according to different ;
73: !error codes ;
74: !e.g.: status=1003 means no ;
75: !point cloud in ROI ;
76: !e.g.: status=1002 means no ;
77: !vision results ;
78: !e.g.: status=3099 means ;
79: !failed to open socket ;
80: PAUSE ;
上述样例程序代码对应的流程如下图所示。
下表为切换Mech-Vision参数配方的逻辑解读。用户单击指令名称的超链接便可查看该指令的详细说明。
| 流程 | 代码及说明 |
|---|---|
切换Mech-Vision参数配方 |
因此,整条指令表示将Mech-Vision工程1的参数配方切换成编号为1的参数配方。
因此,上述语句表示,当状态码R[53]为1107时,则机器人成功切换Mech-Vision参数配方;否则视觉系统发生异常,程序跳转到LBL[99]处执行。以下为LBL[99]处的代码。 |