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