Example Program 17: MM_S17_Vis_ParseLabel

Program Introduction

Description

The robot triggers the Mech-Vision project to run to obtain the vision result, parses the labels, and then adopts a handling method based on the label to perform picking and placing.

File path

You can navigate to the installation directory of Mech-Vision and Mech-Viz and find the file by using the Communication Component/Robot_Interface/FANUC/sample/MM_S17_Vis_ParseLabel path.

Project

Mech-Vision project (data needs to exist in the labels port of the Output Step)

Prerequisites

This example program is provided for reference only. Before using the program, please modify the program according to the actual scenario.

Program Description

This part describes the MM_S17_Vis_ParseLabel example program.

The only difference between the MM_S17_Vis_ParseLabel example program and the MM_S1_Vis_Basic example program is that MM_S17_Vis_ParseLabel can parse labels (the code of this feature is bolded). As such, only the feature of parsing labels is described in the following part. For information about the parts of MM_S17_Vis_ParseLabel that are consistent with those of MM_S1_Vis_Basic, see Example Program 1: MM_S1_Vis_Basic.
   1:  !-------------------------------- ;
   2:  !FUNCTION: trigger Mech-Vision ;
   3:  !project and get vision result, ;
   4:  !then parse the label info ;
   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:  !move to image-capturing position ;
  19:L P[2] 1000mm/sec FINE    ;
  20:  !trigger NO.1 Mech-Vision project ;
  21:  CALL MM_START_VIS(1,0,2,10) ;
  22:  !get vision result from NO.1 ;
  23:  !Mech-Vision project ;
  24:  CALL MM_GET_VIS(1,51,53) ;
  25:  !check whether vision result has ;
  26:  !been got from Mech-Vision ;
  27:  !successfully ;
  28:  IF R[53]<>1100,JMP LBL[99] ;
  29:  !save first vision point data to ;
  30:  !local variables ;
  31:  CALL MM_GET_POS(1,60,70,80) ;
  32:  !parse label info received from ;
  33:  !Mech-Vision, eg. "R[70]=56" ;
  34:  !will decompose into 5 and 6 ;
  35:  R[30]=R[70] DIV 10    ;
  36:  R[31]=R[70] MOD 10    ;
  37:  !add handling logic according to ;
  38:  !decomposed label value ;
  39:  IF (R[30]=5) THEN ;
  40:  !add handling logic a ;
  41:  PAUSE ;
  42:  ELSE ;
  43:  !add handling logic b ;
  44:  PAUSE ;
  45:  ENDIF ;
  46:  !move to intermediate waypoint ;
  47:  !of picking ;
  48:J P[3] 50% CNT100    ;
  49:  !move to approach waypoint ;
  50:  !of picking ;
  51:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  52:  !move to picking waypoint ;
  53:L PR[60] 300mm/sec FINE    ;
  54:  !add object grasping logic here, ;
  55:  !such as "DO[1]=ON" ;
  56:  PAUSE ;
  57:  !move to departure waypoint ;
  58:  !of picking ;
  59:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  60:  !move to intermediate waypoint ;
  61:  !of placing ;
  62:J P[4] 50% CNT100    ;
  63:  !move to approach waypoint ;
  64:  !of placing ;
  65:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  66:  !move to placing waypoint ;
  67:L P[5] 300mm/sec FINE    ;
  68:  !add object releasing logic here, ;
  69:  !such as "DO[1]=OFF" ;
  70:  PAUSE ;
  71:  !move to departure waypoint ;
  72:  !of placing ;
  73:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  74:  !move back to robot home position ;
  75:J P[1] 100% FINE    ;
  76:  END ;
  77:   ;
  78:  LBL[99:vision error] ;
  79:  !add error handling logic here ;
  80:  !according to different ;
  81:  !error codes ;
  82:  !e.g.: status=1003 means no ;
  83:  !point cloud in ROI ;
  84:  !e.g.: status=1002 means no ;
  85:  !vision results ;
  86:  PAUSE ;

The workflow corresponding to the above example program code is shown in the figure below.

sample17

The table below describes the feature of parsing labels. You can click the hyperlink to the command name to view its detailed description.

Feature Code and description

Parse the label as R[30] and R[31]

  32:  !parse label info received from ;
  33:  !Mech-Vision, eg. "R[70]=56" ;
  34:  !will decompose into 5 and 6 ;
  35:  R[30]=R[70] DIV 10    ;
  36:  R[31]=R[70] MOD 10    ;

The MM_GET_POS command stores the TCP, label and tool ID of the vision point in PR[60], R[70], and R[80] respectively. In this example, assuming the value of R[70] is 56, “R[70] DIV 10” represents the quotient of 56 divided by 10 (which is 5), and “R[70] MOD 10” represents the remainder of 56 divided by 10 (which is 6). In this way, 56 is broken down into 5 and 6.

Adopt a handling method based on the label parsing result

  37:  !add handling logic according to ;
  38:  !decomposed label value ;
  39:  IF (R[30]=5) THEN ;
  40:  !add handling logic a ;
  41:  PAUSE ;
  42:  ELSE ;
  43:  !add handling logic b ;
  44:  PAUSE ;
  45:  ENDIF ;

The above code indicates that if R[30] is 5, logic a will be executed; otherwise, logic b will be executed. The handling method varies based on the label parsing result. You can adopt a handling method based on your business requirement.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.