Example Program 6: MM_S6_Viz_ErrorHandle

Program Introduction

Description

The robot starts the Mech-Viz project, obtains the planned path, and then determines whether the planned path is obtained successfully according to the status code. If the planned path is obtained successfully, the robot will perform picking and placing; otherwise, the robot will stop.

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_S6_Viz_ErrorHandle path.

Project

Mech-Vision and Mech-Viz projects

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_S6_Viz_ErrorHandle example program.

The only difference between the MM_S6_Viz_ErrorHandle example program and the MM_S2_Viz_Basic example program is that MM_S6_Viz_ErrorHandle can handle errors based on the different error codes (this code of this feature is bolded). As such, only the feature of handling errors based on the different error codes is described in the following part. For information about the parts of MM_S6_Viz_ErrorHandle that are consistent with those of MM_S2_Viz_Basic, see Example Program 2: 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 ;

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

sample6

The table below describes the feature to process different status codes.

Feature Code and description

Process different status codes

  ...
  16:  R[99]=0    ;
  ...
  25:  LBL[1:vision] ;
  26:  !trigger Mech-Viz project ;
  27:  CALL MM_START_VIZ(2,10) ;
  ...
  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] ;
  ...
  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 ;

After MM_GET_VIZ is executed, the robot stores the received status code in the R[53] register. You can perform the corresponding operation based on the specific received error code.

  • When R[53] is set to 2100, the robot has successfully obtained the planned path. Then, the robot will perform picking by taking the planned path.

  • If R[53] is not set to 2100, an exception has occurred in the vision system and the program will jump to LBL[99] to continue execution. You need to perform the corresponding operation based on the specific error code.

    • If R[53] is set to 2038, it means that the ROI contains no point cloud. In this case, the robot cannot obtain the planned path, and the program will jump to LBL[2] to continue execution. The robot can try to trigger the Mech-Viz project to run again to obtain the planned path. The number of times to re-obtain the planned path is controlled by R[99]. After two retries (i.e., the R[99] value is greater than 2), if no point cloud exists , the program will jump to LBL[999], which means that the execution is stopped.

    • If R[53] is set to any other error code, the program will jump to LBL[999], which means that the execution is stopped.

You can write the error handling code by referring to the Status Codes and Troubleshooting manual.

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.