样例程序5:MM_S5_Viz_SetBranch
程序解读
以下为MM_S5_Viz_SetBranch样例程序的代码及相关解释说明。
与MM_S2_Viz_Basic样例相比,本样例仅新增了设置Mech-Viz消息分支出口的功能(加粗部分的代码)。因此,下文不再重复解释与MM_S2_Viz_Basic样例相同部分的代码(详情请参考MM_S2_Viz_Basic样例说明)。 |
1: !-------------------------------- ;
2: !FUNCTION: trigger Mech-Viz ;
3: !project then set branch and get ;
4: !planned path ;
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',50000,5) ;
18: !move to image-capturing position ;
19:L P[2] 1000mm/sec FINE ;
20: !trigger Mech-Viz project ;
21: CALL MM_START_VIZ(2,10) ;
22: !set branch, "MM_SET_BCH ;
23: !(Branch_Num,Exit_Num)" ;
24: CALL MM_SET_BCH(1,1) ;
25: !get planned path, 1st argument ;
26: !(1) means getting pose in JPs ;
27: CALL MM_GET_VIZ(1,51,52,53) ;
28: !check whether planned path has ;
29: !been got from Mech-Viz ;
30: !successfully ;
31: IF R[53]<>2100,JMP LBL[99] ;
32: !save waypoints of the planned ;
33: !path to local variables one ;
34: !by one ;
35: CALL MM_GET_JPS(1,60,70,80) ;
36: CALL MM_GET_JPS(2,61,71,81) ;
37: CALL MM_GET_JPS(3,62,72,82) ;
38: !follow the planned path to pick ;
39: !move to approach waypoint ;
40: !of picking ;
41:J PR[60] 50% FINE ;
42: !move to picking waypoint ;
43:J PR[61] 10% FINE ;
44: !add object grasping logic here, ;
45: !such as "DO[1]=ON" ;
46: PAUSE ;
47: !move to departure waypoint ;
48: !of picking ;
49:J PR[62] 50% FINE ;
50: !move to intermediate waypoint ;
51: !of placing ;
52:J P[3] 50% CNT100 ;
53: !move to approach waypoint ;
54: !of placing ;
55:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
56: !move to placing waypoint ;
57:L P[4] 300mm/sec FINE ;
58: !add object releasing logic here, ;
59: !such as "DO[1]=OFF" ;
60: PAUSE ;
61: !move to departure waypoint ;
62: !of placing ;
63:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
64: !move back to robot home position ;
65:J P[1] 100% FINE ;
66: END ;
67: ;
68: LBL[99:vision error] ;
69: !add error handling logic here ;
70: !according to different ;
71: !error codes ;
72: !e.g.: status=2038 means no ;
73: !point cloud in ROI ;
74: PAUSE ;
上述样例程序代码对应的流程如下图所示。
下表为设置Mech-Viz消息分支出口的逻辑解读。用户单击指令名称的超链接便可查看该指令的详细说明。
流程 | 代码及说明 |
---|---|
设置Mech-Viz消息分支出口 |
因此,整条指令表示Mech-Viz工程在编号为1的“消息分支”步骤处将沿出口0继续执行,如下图所示。 |