样例程序9:MM_S9_Viz_RunInAdvance
程序解读
以下为MM_S9_Viz_RunInAdvance样例程序的代码及相关解释说明。
与MM_S5_Viz_SetBranch样例相比,本样例仅新增了提前规划下一轮路径的功能(加粗部分的代码)。因此,下文不再重复解释与MM_S5_Viz_SetBranch样例相同部分的代码(详情请参考MM_S5_Viz_SetBranch样例说明)。 |
1: !-------------------------------- ;
2: !FUNCTION: trigger Mech-Viz ;
3: !project then set branch and get ;
4: !planned path, trigger Mech-Viz ;
5: !project and set branch in ;
6: !advance during pick&place proces ;
7: !process ;
8: !Mech-Mind, 2023-12-25 ;
9: !-------------------------------- ;
10: ;
11: !set current uframe NO. to 0 ;
12: UFRAME_NUM=0 ;
13: !set current tool NO. to 1 ;
14: UTOOL_NUM=1 ;
15: !move to robot home position ;
16:J P[1] 100% FINE ;
17: !initialize communication ;
18: !parameters(initialization is ;
19: !required only once) ;
20: CALL MM_INIT_SKT('8','127.0.0.1',50000,5) ;
21: !move to image-capturing position ;
22:L P[2] 1000mm/sec FINE ;
23: !trigger Mech-Viz project ;
24: CALL MM_START_VIZ(2,10) ;
25: !set branch, "MM_SET_BCH ;
26: !(Branch_Num,Exit_Num)" ;
27: CALL MM_SET_BCH(1,1) ;
28: LBL[1:LOOP] ;
29: !get planned path, 1st argument ;
30: !(1) means getting pose in JPs ;
31: CALL MM_GET_VIZ(1,51,52,53) ;
32: !check whether planned path has ;
33: !been got from Mech-Viz ;
34: !successfully ;
35: IF R[53]<>2100,JMP LBL[99] ;
36: !save waypoints of the planned ;
37: !path to local variables one ;
38: !by one ;
39: CALL MM_GET_JPS(1,60,70,80) ;
40: CALL MM_GET_JPS(2,61,71,81) ;
41: CALL MM_GET_JPS(3,62,72,82) ;
42: !follow the planned path to pick ;
43: !move to approach waypoint ;
44: !of picking ;
45:J PR[60] 50% FINE ;
46: !move to picking waypoint ;
47:J PR[61] 10% FINE ;
48: !add object grasping logic here, ;
49: !such as "DO[1]=ON" ;
50: PAUSE ;
51: !trigger Mech-Viz project but not ;
52: !to trigger camera capturing ;
53: CALL MM_START_VIZ(2,10) ;
54: !move to departure waypoint ;
55: !of picking ;
56:J PR[62] 50% FINE ;
57: !move to intermediate waypoint ;
58: !of placing ;
59:J P[3] 50% CNT100 ;
60: !move to approach waypoint ;
61: !of placing ;
62:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
63: !set branch exit port and trigger ;
64: !camera capturing when robot ;
65: !moves out of camera’s field of ;
66: !view ;
67: CALL MM_SET_BCH(1,1) ;
68: !move to placing waypoint ;
69:L P[4] 300mm/sec FINE ;
70: !add object releasing logic here, ;
71: !such as "DO[1]=OFF" ;
72: PAUSE ;
73: !move to departure waypoint ;
74: !of placing ;
75:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
76: !move back to robot home position ;
77:J P[1] 100% FINE ;
78: JMP LBL[1] ;
79: END ;
80: ;
81: LBL[99:vision error] ;
82: !add error handling logic here ;
83: !according to different ;
84: !error codes ;
85: !e.g.: status=2038 means no ;
86: !point cloud in ROI ;
87: PAUSE ;
上述样例程序代码对应的流程如下图所示。
以下为提前规划下一轮路径的代码及相关解释说明。
流程 | 代码及说明 | ||
---|---|---|---|
通过循环(抓取→触发下一轮规划→放置)提前规划下一轮路径 |
上述代码表示,程序循环执行LBL[1]处的代码。
上述代码表示,机器人通过MM_GET_VIZ指令获取Mech-Viz规划的路径。
上述代码表示,机器人通过MM_GET_JPS指令将规划路径转存至指定寄存器。本样例假设PR[60]、PR[61]、PR[62]分别为抓取接近点、抓取点、抓取离开点。
上述代码表示,机器人依次移动到抓取接近点、抓取点,然后设置DO指令(例如,DO[1]=ON),控制末端工具进行抓取。
上述代码表示,机器人通过MM_START_VIZ指令再次触发Mech-Viz工程运行。此时机器人已获取到规划的抓取路径,且已移动至抓取点,因此可以提前触发Mech-Viz工程运行以规划下一轮路径,而不必等待放置完成后再触发Mech-Viz工程运行。
上述代码表示,机器人依次移动到抓取离开点(PR[62])、中间过渡点(P[3])、放置接近点(Tool_Offset,PR[2])。
上述代码表示,机器人通过MM_SET_BCH指令设置“消息分支”步骤的出口。在该出口分支上,“视觉识别”步骤将被执行,Mech-Viz根据视觉识别结果提前规划下一轮抓取路径。
上述代码表示,机器人先移动到放置点(P[4]),然后进行放置操作(例如,DO[1]=OFF),然后依次移动到放置离开点(Tool_Offset,PR[2])、Home点。 |