样例程序6:MM_S6_Viz_ErrorHandle
程序解读
以下为MM_S6_Viz_ErrorHandle样例程序的代码及相关解释说明。
与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: !handle errors according to ;
5: !status codes (if no point cloud ;
6: !in ROI, retry several times ;
7: !before exit loop) ;
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: !reset counter ;
16: R[99]=0 ;
17: !move to robot home position ;
18:J P[1] 100% FINE ;
19: !initialize communication ;
20: !parameters(initialization is ;
21: !required only once) ;
22: CALL MM_INIT_SKT('8','127.0.0.1',50000,5) ;
23: !move to image-capturing position ;
24:L P[2] 1000mm/sec FINE ;
25: LBL[1:vision] ;
26: !trigger Mech-Viz project ;
27: CALL MM_START_VIZ(2,10) ;
28: !get planned path, 1st argument ;
29: !(1) means getting pose in JPs ;
30: CALL MM_GET_VIZ(1,51,52,53) ;
31: !check whether planned path has ;
32: !been got from Mech-Viz ;
33: !successfully ;
34: IF R[53]<>2100,JMP LBL[99] ;
35: !save waypoints of the planned ;
36: !path to local variables one ;
37: !by one ;
38: CALL MM_GET_JPS(1,60,70,80) ;
39: CALL MM_GET_JPS(2,61,71,81) ;
40: CALL MM_GET_JPS(3,62,72,82) ;
41: !follow the planned path to pick ;
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: IF R[53]=2038,JMP LBL[2] ;
73: JMP LBL[999] ;
74: ;
75: LBL[2] ;
76: !no point cloud in ROI, add ;
77: !handling logic here ;
78: !self-adding then check retry ;
79: !counter ;
80: R[99]=R[99]+1 ;
81: !jump back to vision retry label ;
82: !if the number of retry times is ;
83: !less than 3 ;
84: IF R[99]<3,JMP LBL[1] ;
85: !reset counter and exit loop if ;
86: !the number of retry times has ;
87: !reached 3 ;
88: R[99]=0 ;
89: JMP LBL[999] ;
90: ;
91: LBL[999:other error] ;
92: !add other error handling logic ;
93: !here ;
94: PAUSE ;
上述样例程序代码对应的流程如下图所示。
下表为处理不同状态码的逻辑解读。
流程 | 代码及说明 | ||
---|---|---|---|
处理不同状态码 |
机器人在执行MM_GET_VIZ指令后,会将指令执行的状态码保存至R[53]寄存器。用户可根据具体状态码做相应的处理,如本例中的处理逻辑。
|