样例程序11:MM_S11_Viz_Timer
程序解读
以下为MM_S11_Viz_Timer样例程序的代码及相关解释说明。
与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: !add a timer to record cycle time ;
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: LBL[1:LOOP] ;
19: !reset timer to 0 ;
20: TIMER[1]=RESET ;
21: !start timer ;
22: TIMER[1]=START ;
23: !move to image-capturing position ;
24:L P[2] 1000mm/sec FINE ;
25: !trigger Mech-Viz project ;
26: CALL MM_START_VIZ(2,10) ;
27: !get planned path, 1st argument ;
28: !(1) means getting pose in JPs ;
29: CALL MM_GET_VIZ(1,51,52,53) ;
30: !check whether planned path has ;
31: !been got from Mech-Viz ;
32: !successfully ;
33: IF R[53]<>2100,JMP LBL[99] ;
34: !save waypoints of the planned ;
35: !path to local variables one ;
36: !by one ;
37: CALL MM_GET_JPS(1,60,70,80) ;
38: CALL MM_GET_JPS(2,61,71,81) ;
39: CALL MM_GET_JPS(3,62,72,82) ;
40: !follow the planned path to pick ;
41: !move to approach waypoint ;
42: !of picking ;
43:J PR[60] 50% FINE ;
44: !move to picking waypoint ;
45:J PR[61] 10% FINE ;
46: !add object grasping logic here, ;
47: !such as "DO[1]=ON" ;
48: PAUSE ;
49: !move to departure waypoint ;
50: !of picking ;
51:J PR[62] 50% FINE ;
52: !move to intermediate waypoint ;
53: !of placing ;
54:J P[3] 50% CNT100 ;
55: !move to approach waypoint ;
56: !of placing ;
57:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
58: !move to placing waypoint ;
59:L P[4] 300mm/sec FINE ;
60: !add object releasing logic here, ;
61: !such as "DO[1]=OFF" ;
62: PAUSE ;
63: !move to departure waypoint ;
64: !of placing ;
65:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
66: !move back to robot home position ;
67:J P[1] 100% FINE ;
68: !stop timer ;
69: TIMER[1]=STOP ;
70: !save timer value to register ;
71: R[99]=TIMER[1] ;
72: JMP LBL[1] ;
73: END ;
74: ;
75: LBL[99:vision error] ;
76: !add error handling logic here ;
77: !according to different ;
78: !error codes ;
79: !e.g.: status=2038 means no ;
80: !point cloud in ROI ;
81: PAUSE ;
上述样例程序代码对应的流程如下图所示。
下表为计时器的逻辑解读。
流程 | 代码及说明 |
---|---|
通过循环计算每次从建立通信到完成抓取与放置所花费的时间 |
上述代码表示,程序循环执行LBL[1]处的代码。
上述代码表示,将计时器TIMER[1]重置为0。
上述代码表示,计时器TIMER[1]开始计时。
上述代码表示,计时器TIMER[1]结束计时。
上述代码表示,将计时器TIMER[1]的值赋值给R[99]寄存器,方便读取计时器计算的时间(即每次从建立通信到完成抓取与放置所花费的时间)。 |