Example Program 5: MM_S5_Viz_SetBranch

Program Introduction

Description

The robot triggers the Mech-Viz project to run, sets the exit port for the Branch by Msg Step in the Mech-Viz project, and then obtains the planned path for 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_S5_Viz_SetBranch 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_S5_Viz_SetBranch example program.

The only difference between the MM_S5_Viz_SetBranch example program and the MM_S2_Viz_Basic example program is that MM_S5_Viz_SetBranch can set the exit port of the Branch by Msg Step in the Mech-Viz project (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 then set branch and get ;
   4:  !planned path ;
   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 Mech-Viz project ;
  21:  CALL MM_START_VIZ(2,10) ;
  22:  !set branch, "MM_SET_BCH ;
  23:  !(Branch_Num,Exit_Num)" ;
  24:  CALL MM_SET_BCH(1,1) ;
  25:  !get planned path, 1st argument ;
  26:  !(1) means getting pose in JPs ;
  27:  CALL MM_GET_VIZ(1,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:  !save waypoints of the planned ;
  33:  !path to local variables one ;
  34:  !by one ;
  35:  CALL MM_GET_JPS(1,60,70,80) ;
  36:  CALL MM_GET_JPS(2,61,71,81) ;
  37:  CALL MM_GET_JPS(3,62,72,82) ;
  38:  !follow the planned path to pick ;
  39:  !move to approach waypoint ;
  40:  !of picking ;
  41:J PR[60] 50% FINE    ;
  42:  !move to picking waypoint ;
  43:J PR[61] 10% FINE    ;
  44:  !add object grasping logic here, ;
  45:  !such as "DO[1]=ON" ;
  46:  PAUSE ;
  47:  !move to departure waypoint ;
  48:  !of picking ;
  49:J PR[62] 50% FINE    ;
  50:  !move to intermediate waypoint ;
  51:  !of placing ;
  52:J P[3] 50% CNT100    ;
  53:  !move to approach waypoint ;
  54:  !of placing ;
  55:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  56:  !move to placing waypoint ;
  57:L P[4] 300mm/sec FINE    ;
  58:  !add object releasing logic here, ;
  59:  !such as "DO[1]=OFF" ;
  60:  PAUSE ;
  61:  !move to departure waypoint ;
  62:  !of placing ;
  63:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  64:  !move back to robot home position ;
  65:J P[1] 100% FINE    ;
  66:  END ;
  67:   ;
  68:  LBL[99:vision error] ;
  69:  !add error handling logic here ;
  70:  !according to different ;
  71:  !error codes ;
  72:  !e.g.: status=2038 means no ;
  73:  !point cloud in ROI ;
  74:  PAUSE ;

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

sample5

The table below describes the process of setting the exit port of the Branch by Msg Step in the Mech-Viz project. You can click the hyperlink to the command name to view its detailed description.

Feature Code and description

Set the exit port for the Branch by Msg Step in Mech-Viz

  22:  !set branch, "MM_SET_BCH ;
  23:  !(Branch_Num,Exit_Num)" ;
  24:  CALL MM_SET_BCH(1,1) ;
  • MM_SET_BCH: The command to set the exit port for the Branch by Msg Step in Mech-Viz.

  • First 1: The Step ID of the Branch by Msg Step.

  • Second 1: The Mech-Viz project takes exit port 0 of the Branch by Msg Step. Note that if this parameter is set to N, the exit port is N-1.

In the entire statement, the Mech-Viz project with an ID of 1 takes the port 0 of the Branch by Msg Step, as shown in the following figure.

set branch

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.