样例程序9:MM_S9_Viz_RunInAdvance

程序简介

功能说明

机器人在抓取时触发Mech-Viz工程,然后通过消息分支在放置时触发相机拍照,从而提前规划下一轮路径,以缩短节拍。

文件路径

Mech-Vision和Mech-Viz软件安装目录下Communication Component/Robot_Interface/FANUC/sample/MM_S9_Viz_RunInAdvance

所需工程

Mech-Vision工程和Mech-Viz工程

Mech-Viz工程需提前配置消息分支

使用前提

  1. 已完成标准接口通信配置

  2. 已完成自动标定

此样例程序仅是示例程序。用户需根据实际情况在此基础上进行修改,请勿直接使用该程序。

程序解读

以下为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 ;

上述样例程序代码对应的流程如下图所示。

sample9

以下为提前规划下一轮路径的代码及相关解释说明。

流程 代码及说明

通过循环(抓取→触发下一轮规划→放置)提前规划下一轮路径

  28:  LBL[1:LOOP] ;
  ...
  78:  JMP LBL[1] ;

上述代码表示,程序循环执行LBL[1]处的代码。

  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] ;

上述代码表示,机器人通过MM_GET_VIZ指令获取Mech-Viz规划的路径。

  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) ;

上述代码表示,机器人通过MM_GET_JPS指令将规划路径转存至指定寄存器。本样例假设PR[60]、PR[61]、PR[62]分别为抓取接近点、抓取点、抓取离开点。

  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 ;

上述代码表示,机器人依次移动到抓取接近点、抓取点,然后设置DO指令(例如,DO[1]=ON),控制末端工具进行抓取。

  51:  !trigger Mech-Viz project but not ;
  52:  !to trigger camera capturing ;
  53:  CALL MM_START_VIZ(2,10) ;

上述代码表示,机器人通过MM_START_VIZ指令再次触发Mech-Viz工程运行。此时机器人已获取到规划的抓取路径,且已移动至抓取点,因此可以提前触发Mech-Viz工程运行以规划下一轮路径,而不必等待放置完成后再触发Mech-Viz工程运行。

Mech-Viz工程一旦运行,在执行到“消息分支”步骤时,会等待MM_SET_BCH指令设置其分支出口。另外,“视觉识别”步骤(执行相机拍照)设置在“消息分支”步骤的某个分支上,因此相机此时并未执行拍照。
  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]    ;

上述代码表示,机器人依次移动到抓取离开点(PR[62])、中间过渡点(P[3])、放置接近点(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) ;

上述代码表示,机器人通过MM_SET_BCH指令设置“消息分支”步骤的出口。在该出口分支上,“视觉识别”步骤将被执行,Mech-Viz根据视觉识别结果提前规划下一轮抓取路径。

  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    ;

上述代码表示,机器人先移动到放置点(P[4]),然后进行放置操作(例如,DO[1]=OFF),然后依次移动到放置离开点(Tool_Offset,PR[2])、Home点。

我们重视您的隐私

我们使用 cookie 为您在我们的网站上提供最佳体验。继续使用该网站即表示您同意使用 cookie。如果您拒绝,将使用一个单独的 cookie 来确保您在访问本网站时不会被跟踪或记住。