样例程序18:MM_S18_Viz_GetUserData
程序解读
以下为MM_S18_Viz_GetUserData样例程序的代码及相关解释说明。
| 与MM_S15_Viz_GetDoList样例相比,本样例仅修改了如下加粗部分的代码。因此,下文不再重复解释与MM_S15_Viz_GetDoList样例相同部分的代码(详情请参考MM_S15_Viz_GetDoList样例说明)。 |
1: !-------------------------------- ;
2: !FUNCTION: trigger Mech-Viz ;
3: !project, then get planned path ;
4: !and get custom data from ;
5: !Mech-Vision using command 210 ;
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 ;
27: CALL MM_GET_PLNDT(0,3,51,52,53) ;
28: !check whether planned path has ;
29: !been got from Mech-Viz ;
30: !successfully ;
31: IF R[53]<>2100,JMP LBL[99] ;
32: !get gripper control signal list ;
33: CALL MM_GET_DL(0,0,53) ;
34: !check whether viz DoList has ;
35: !been gotten successfully ;
36: IF (R[53]<>2102),JMP LBL[99] ;
37: !save waypoints of the planned ;
38: !path to local variables one ;
39: !by one ;
40: CALL MM_GET_PLJOP(1,3,60,61,62,63,64,70) ;
41: CALL MM_GET_PLJOP(2,3,61,91,92,93,94,100) ;
42: CALL MM_GET_PLJOP(3,3,62,121,122,123,124,130) ;
43: !save received custom data of ;
44: !2nd point ;
45: R[10]=R[94] ;
46: R[11]=R[95] ;
47: R[12]=R[96] ;
48: !follow the planned path to pick ;
49: !move to approach waypoint ;
50: !of picking ;
51:J PR[60] 50% FINE ;
52: !move to picking waypoint ;
53:J PR[61] 10% FINE ;
54: !add object grasping logic here ;
55: PAUSE ;
56: !set gripper control signal ;
57: CALL MM_SET_DL(0) ;
58: !move to departure waypoint ;
59: !of picking ;
60:J PR[62] 50% FINE ;
61: !move to intermediate waypoint ;
62: !of placing ;
63:J P[3] 50% CNT100 ;
64: !move to approach waypoint ;
65: !of placing ;
66:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
67: !move to placing waypoint ;
68:L P[4] 300mm/sec FINE ;
69: !add object releasing logic here, ;
70: !such as "DO[1]=OFF" ;
71: PAUSE ;
72: !move to departure waypoint ;
73: !of placing ;
74:L P[4] 1000mm/sec FINE Tool_Offset,PR[2] ;
75: !move back to robot home position ;
76:J P[1] 100% FINE ;
77: END ;
78: ;
79: LBL[99:vision error] ;
80: !add error handling logic here ;
81: !according to different ;
82: !error codes ;
83: !e.g.: status=2038 means no ;
84: !point cloud in ROI ;
85: !e.g.: mm_status=3099 means ;
86: !failed to open socket ;
87: PAUSE ;
上述样例程序代码对应的流程如下图所示。
下表为新增代码的逻辑解读。用户单击指令名称的超链接便可查看该指令的详细说明。
| 流程 | 代码及说明 | ||||
|---|---|---|---|---|---|
保存路径点的自定义数据 |
机器人通过MM_GET_PLNDT指令获取路径点的视觉移动规划数据和自定义数据,然后再通过MM_GET_PLJOP指令将路径点的视觉移动规划数据和自定义数据从机器人内存中转存至指定寄存器中。示例中,抓取点(PR[61])的自定义数据从R[94]开始存放。 上述代码表示,将视觉移动路径点(抓取点)的三个自定义数据R[94]、R[95]和R[96]分别赋值给R[10]、R[11]和R[12]。
|