样例程序12:MM_S12_Viz_ForLoop
程序解读
以下为MM_S12_Viz_ForLoop样例程序的代码及相关解释说明。
MM_S2_Viz_Basic是逐个转存规划的路径点,本样例是通过循环转存规划的路径点(加粗部分的代码)。因此,下文不再重复解释与MM_S2_Viz_Basic样例相同部分的代码(详情请参考MM_S2_Viz_Basic样例说明)。 |
1: !-------------------------------- ;
2: !FUNCTION: trigger Mech-Viz ;
3: !project and get planned path, ;
4: !get poses using for-loop ;
5: !structure ;
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 Mech-Viz project ;
22: CALL MM_START_VIZ(2,10) ;
23: !get planned path, 1st argument ;
24: !(1) means getting pose in JPs ;
25: CALL MM_GET_VIZ(1,51,52,53) ;
26: !check whether planned path has ;
27: !been got from Mech-Viz ;
28: !successfully ;
29: IF R[53]<>2100,JMP LBL[99] ;
30: !save waypoints of the planned ;
31: !path to local variables using ;
32: !for-loop structure ;
33: FOR R[100]=1 TO R[51] ;
34: R[101]=59+R[100] ;
35: R[102]=69+R[100] ;
36: R[103]=79+R[100] ;
37: CALL MM_GET_JPS(R[100],R[101],R[102],R[103]) ;
38: ENDFOR ;
39: !follow the planned path to pick, ;
40: !in this example waypoint 2 ;
41: !(PR[61]) is picking waypoint ;
42: !move to approach waypoint ;
43: !of picking ;
44:J PR[60] 50% FINE ;
45: !move to picking waypoint ;
46:J PR[61] 10% FINE ;
47: !add object grasping logic here, ;
48: !such as "DO[1]=ON" ;
49: PAUSE ;
50: !move to departure waypoint ;
51: !of picking ;
52:J PR[62] 50% FINE ;
53: !move to intermediate waypoint ;
54: !of placing ;
55:J P[3] 50% CNT100 ;
56: !move to approach waypoint ;
57: !of placing ;
58:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
59: !move to placing waypoint ;
60:L P[4] 300mm/sec FINE ;
61: !add object releasing logic here, ;
62: !such as "DO[1]=OFF" ;
63: PAUSE ;
64: !move to departure waypoint ;
65: !of placing ;
66:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
67: !move back to robot home position ;
68:J P[1] 100% FINE ;
69: END ;
70: ;
71: LBL[99:vision error] ;
72: !add error handling logic here ;
73: !according to different ;
74: !error codes ;
75: !e.g.: status=2038 means no ;
76: !point cloud in ROI ;
77: PAUSE ;
上述样例程序代码对应的流程如下图所示。
下表为通过循环转存规划路径的逻辑解读。用户单击指令名称的超链接便可查看该指令的详细说明。
流程 | 代码及说明 |
---|---|
通过循环转存规划路径 |
假设本样例规划的路径有3个路径点,则上述循环等同于MM_S2_Viz_Basic样例中如下三条指令。
|