Example Program 19: MM_S19_Vis_PlanAllVision

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 robot triggers the Mech-Vision project to run. Then, the robot uses for loops to obtain all planned paths and perform picking and placing. In this example, once the camera captures an image, Mech-Vision will plan picking paths for all vision results. This program is applicable to scenarios where one image is used to perform picking for multiple times.

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

Project

Mech-Vision project

In this project, the Plan all vision results parameter of the Global Configuration Step on the Workflow tab in the path planning tool is enabled. You can click Open the editor on the Path Planning Step to open the path planning tool.
sample19 1

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

The only difference between the MM_S19_Vis_PlanAllVision example program and the MM_S3_Vis_Path example program is that MM_S19_Vis_PlanAllVision can use for loops to obtain all planned paths and perform picking and placing (this code of this feature is bolded). As such, only the feature of using for loops to obtain all planned paths and perform picking and placing is described in the following part. For information about the parts of MM_S19_Vis_PlanAllVision that are consistent with those of MM_S3_Vis_Path, see Example Program: MM_S3_Vis_Path.
   1:  !-------------------------------- ;
   2:  !FUNCTION: trigger Mech-Vision ;
   3:  !project, plan all vision results ;
   4:  !and get all planned paths ;
   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:  LBL[1:recap] ;
  19:  !move to image-capturing position ;
  20:L P[2] 1000mm/sec FINE    ;
  21:  !trigger NO.1 Mech-Vision project ;
  22:  CALL MM_START_VIS(1,0,2,10) ;
  23:  !get planned path from NO.1 ;
  24:  !Mech-Vision project; 2nd ;
  25:  !argument (1) means getting pose ;
  26:  !in JPs ;
  27:  CALL MM_GET_VISP(1,1,51,52,53) ;
  28:  !check whether planned path has ;
  29:  !been got from Mech-Vision ;
  30:  !successfully ;
  31:  IF R[53]<>1103,JMP LBL[99] ;
  32:  !save all waypoint data to local ;
  33:  !variables using for-loop, a ;
  34:  !maximum of 50 points are support ;
  35:  !supported ;
  36:  FOR R[10]=1 TO R[51] ;
  37:  R[11]=59+R[10]    ;
  38:  R[12]=69+R[10]    ;
  39:  R[13]=99+R[10]    ;
  40:  CALL MM_GET_JPS(R[10],R[11],R[12],R[13]) ;
  41:  ENDFOR ;
  42:  !parse pick cycle count, here ;
  43:  !suppose 5 points per planned ;
  44:  !path ;
  45:  R[30]=R[51] DIV 5    ;
  46:  R[29]=R[51] MOD 5    ;
  47:  !check if parsed data is valid; ;
  48:  !if not, retry to get planned ;
  49:  !path or add some error handling ;
  50:  !logic ;
  51:  IF R[30]<1) OR (R[29]<>0 THEN ;
  52:  PAUSE ;
  53:  JMP LBL[1] ;
  54:  ENDIF ;
  55:  !repeatedly run pick-and-place ;
  56:  !cycle using for-loop ;
  57:  FOR R[10]=1 TO R[30] ;
  58:  R[20]=R[10]-1    ;
  59:  R[21]=R[20]*5    ;
  60:  R[31]=60+R[21]    ;
  61:  R[32]=61+R[21]    ;
  62:  R[33]=62+R[21]    ;
  63:  R[34]=63+R[21]    ;
  64:  R[35]=64+R[21]    ;
  65:  !follow the planned path to pick ;
  66:J PR[R[31]] 50% CNT100    ;
  67:J PR[R[32]] 50% FINE    ;
  68:J PR[R[33]] 10% FINE    ;
  69:  !add object grasping logic here, ;
  70:  !such as "DO[1]=ON" ;
  71:  PAUSE ;
  72:J PR[R[34]] 50% FINE    ;
  73:J PR[R[35]] 50% CNT100    ;
  74:  !move to intermediate waypoint ;
  75:  !of placing ;
  76:J P[3] 50% CNT100    ;
  77:  !move to approach waypoint ;
  78:  !of placing ;
  79:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  80:  !move to placing waypoint ;
  81:L P[4] 300mm/sec FINE    ;
  82:  !add object releasing logic here, ;
  83:  !such as "DO[1]=OFF" ;
  84:  PAUSE ;
  85:  !move to departure waypoint ;
  86:  !of placing ;
  87:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  88:  !move to intermediate waypoint ;
  89:  !of placing ;
  90:J P[3] 50% CNT100    ;
  91:  ENDFOR ;
  92:  !finish pick-and-place cycle, and ;
  93:  !jump back to camera capturing ;
  94:  JMP LBL[1] ;
  95:  END ;
  96:   ;
  97:  LBL[99:vision error] ;
  98:  !add error handling logic here ;
  99:  !according to different ;
 100:  !error codes ;
 101:  !e.g.: status=1003 means no ;
 102:  !point cloud in ROI ;
 103:  !e.g.: status=1002 means no ;
 104:  !vision results ;
 105:  PAUSE ;

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

sample19

The table below describes the feature of using for loops to obtain all planned paths and perform picking and placing. You can click the hyperlink to the command name to view its detailed description.

Feature Code and description

Store the planned path by looping

  32:  !save all waypoint data to local ;
  33:  !variables using for-loop, a ;
  34:  !maximum of 50 points are support ;
  35:  !supported ;
  36:  FOR R[10]=1 TO R[51] ;
  37:  R[11]=59+R[10]    ;
  38:  R[12]=69+R[10]    ;
  39:  R[13]=99+R[10]    ;
  40:  CALL MM_GET_JPS(R[10],R[11],R[12],R[13]) ;
  41:  ENDFOR ;
  • Line 36: FOR indicates the start of a loop segment. R[10] is used to control the number of iterations (beginning at 1, R[10] increments by 1 after each iteration until it surpasses the value set in R[51], at which point the loop ends). R[51] is the numeric register indicated by the third parameter in the MM_GET_VISP command. The numeric register stores the number of waypoints that are returned by the vision system. As such, R[10] can indicate the position ID of the current waypoint in the planned path.

  • Lines 37 to 39: R[11], R[12], and R[13] represent the registers used for the joint positions, label, and tool ID that correspond to the current waypoint, respectively.

  • Line 40: The MM_Get_Jps command stores the joint positions, label, and tool ID of a specific waypoint in the specific registers. The entire command stores the joint positions, label, and tool ID of the waypoint with an ID of the R[10] value in the R[11], R[12], and R[13] registers respectively.

Calculate the values for R[30] and R[29]

  42:  !parse pick cycle count, here ;
  43:  !suppose 5 points per planned ;
  44:  !path ;
  45:  R[30]=R[51] DIV 5    ;
  46:  R[29]=R[51] MOD 5    ;

This example assumes that each planned picking path consists of 5 waypoints. “R[51] DIV 5” indicates the quotient when the value of R[51] is divided by 5, and “R[51] MOD 5” indicates the remainder when the value of R[51] is divided by 5. R[30] indicates the total number of picking times. If R[29] is not set to 0, the planned number of picking waypoints is less than 5 (i.e., an error has occurred during path planning and a re-planning operation is needed).

Determine whether an error has occurred during path planning

  47:  !check if parsed data is valid; ;
  48:  !if not, retry to get planned ;
  49:  !path or add some error handling ;
  50:  !logic ;
  51:  IF ((R[30]<1) OR (R[29]<>0)) THEN ;
  52:  PAUSE ;
  53:  JMP LBL[1] ;
  54:  ENDIF ;

If the number of picking times (R[30]) is less than 1 or the value of R[29] is not 0, an error has occurred during path planning. You need to add processing code here, such as the code to restart the Mech-Vision project and then obtain the planned path.

Perform picking and placing by looping

  55:  !repeatedly run pick-and-place ;
  56:  !cycle using for-loop ;
  57:  FOR R[10]=1 TO R[30] ;
  58:  R[20]=R[10]-1    ;
  59:  R[21]=R[20]*5    ;
  60:  R[31]=60+R[21]    ;
  61:  R[32]=61+R[21]    ;
  62:  R[33]=62+R[21]    ;
  63:  R[34]=63+R[21]    ;
  64:  R[35]=64+R[21]    ;
  65:  !follow the planned path to pick ;
  66:J PR[R[31]] 50% CNT100    ;
  67:J PR[R[32]] 50% FINE    ;
  68:J PR[R[33]] 10% FINE    ;
  69:  !add object grasping logic here, ;
  70:  !such as "DO[1]=ON" ;
  71:  PAUSE ;
  72:J PR[R[34]] 50% FINE    ;
  73:J PR[R[35]] 50% CNT100    ;
  74:  !move to intermediate waypoint ;
  75:  !of placing ;
  76:J P[3] 50% CNT100    ;
  77:  !move to approach waypoint ;
  78:  !of placing ;
  79:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  80:  !move to placing waypoint ;
  81:L P[4] 300mm/sec FINE    ;
  82:  !add object releasing logic here, ;
  83:  !such as "DO[1]=OFF" ;
  84:  PAUSE ;
  85:  !move to departure waypoint ;
  86:  !of placing ;
  87:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  88:  !move to intermediate waypoint ;
  89:  !of placing ;
  90:J P[3] 50% CNT100    ;
  91:  ENDFOR ;

The above code indicates that in the for loop, the robot moves to the 5 waypoints planned each time to complete the picking operation and then performs the placing operation. R[10] is used to control the number of iterations in the loop (i.e., the value of R[10] starts from 1 and increments by 1 after each loop iteration until it exceeds the value of R[30], at which point the loop ends. Each time the value of R[10] increases by 1, the value of R[21] is incremented by 5. The range 60+R[21] to 64+R[21] (i.e., R[31] to R[35]) corresponds to the register IDs where the 5 waypoints of each planned path will be stored.

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.