Example Program 9: MM_S9_Viz_RunInAdvance

You are currently viewing the documentation for the latest version (2.1.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

Program Introduction

Description

The Mech-Viz project is triggered when the robot performs picking. Then, the camera is started by the Branch by Msg Step of the project when the robot performs placing to plan the next path, shortening the cycle time.

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

Project

Mech-Vision and Mech-Viz projects

The Mech-Viz project requires that the Branch by Msg Step be configured beforehand.

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

The only difference between the MM_S9_Viz_RunInAdvance example program and the MM_S5_Viz_SetBranch example program is that MM_S9_Viz_RunInAdvance can plan the next path (this code of this feature is bolded). As such, only the feature of planning the next path is described in the following part. For information about the parts of MM_S9_Viz_RunInAdvance that are consistent with those of MM_S5_Viz_SetBranch, see Example Program 5: 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 ;

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

sample9

The following part describes the feature of planning the next path.

Feature Code and description

Plan the next path in advance by looping (picking→triggering the next round of path planning→placing)

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

The above code indicates that the program repeatedly executes the code at 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] ;

The above code indicates that the robot obtains the planned path from Mech-Viz by running the MM_GET_VIZ command.

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

The above code indicates that the robot stores the planned path in the specified register by running the MM_GET_JPS command. This example assumes that PR[60], PR[61], and PR[62] are the approach waypoint of picking, the picking waypoint, and the departure waypoint of picking.

  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 ;

The above code indicates that the robot moves to the approach waypoint of picking and then to the picking waypoint, and then the DO command (such as DO[1]=ON) is run to control the tool to perform picking.

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

The above code indicates that the robot runs the MM_START_VIZ command to start the Mech-Viz project again. Now that the robot has obtained the planned picking path and has moved to the picking waypoint, you can start the Mech-Viz project in advance to plan the next path instead of waiting for the placing to complete and then starting the Mech-Viz project.

Once the Mech-Viz project is executed, the project will wait for the MM_SET_BCH command to set the exit port for the Branch by Msg Step. In addition, the Visual Recognition Step (which performs image capturing) was set on a branch of the Branch by Msg Step, so the camera does not perform image capturing at this time point.
  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]    ;

The above code indicates that the robot moves to the departure waypoint of picking (PR[62]), the intermediate waypoint (P[3]), and then the approach waypoint of placing (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) ;

In the above code, the robot sets the exit port of the Branch by Msg Step with the MM_SET_BCH command. On this exit port, the Visual Recognition Step will be executed. Then, Mech-Viz will plan the next picking path in advance based on the vision result.

  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    ;

In the above example, the robot moves to the placing waypoint (P[4]), performs placing (for example, DO[1]=OFF), and then moves to the departure waypoint of placing (Tool_Offset,PR[2]) and then the home position.

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.