Example Program 4: MM_S4_Vis_ChangeModel

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 switches the Mech-Vision parameter recipe, and then triggers the Mech-Vision project to run to obtain the vision result 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_S4_Vis_ChangeModel path.

Project

Mech-Vision project

The parameter recipe must be configured beforehand for the Mech-Vision project.

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

The only difference between the MM_S4_Vis_ChangeModel example program and the MM_S1_Vis_Basic example program is that MM_S4_Vis_ChangeModel can switch the parameter recipe in the Mech-Vision project (this code of this feature is bolded). As such, only the feature of switching the parameter recipe is described in the following part. For information about the parts of MM_S4_Vis_ChangeModel 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 after switching recipe ;
   4:  !and get vision result ;
   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:  !switch recipe of NO.1 ;
  21:  !Mech-Vision project, ;
  22:  !"MM_SET_MOD(Proj_num,Model_num)" ;
  23:  CALL MM_SET_MOD(1,1) ;
  24:  !trigger NO.1 Mech-Vision project ;
  25:  CALL MM_START_VIS(1,0,2,10) ;
  26:  !get vision result from NO.1 ;
  27:  !Mech-Vision project ;
  28:  CALL MM_GET_VIS(1,51,53) ;
  29:  !check whether vision result has ;
  30:  !been got from Mech-Vision ;
  31:  !successfully ;
  32:  IF R[53]<>1100,JMP LBL[99] ;
  33:  !save first vision point data to ;
  34:  !local variables ;
  35:  CALL MM_GET_POS(1,60,70,80) ;
  36:  !move to intermediate waypoint ;
  37:  !of picking ;
  38:J P[3] 50% CNT100    ;
  39:  !move to approach waypoint ;
  40:  !of picking ;
  41:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  42:  !move to picking waypoint ;
  43:L PR[60] 300mm/sec FINE    ;
  44:  !add object grasping logic here, ;
  45:  !such as "DO[1]=ON" ;
  46:  PAUSE ;
  47:  !move to departure waypoint ;
  48:  !of picking ;
  49:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  50:  !move to intermediate waypoint ;
  51:  !of placing ;
  52:J P[4] 50% CNT100    ;
  53:  !move to approach waypoint ;
  54:  !of placing ;
  55:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  56:  !move to placing waypoint ;
  57:L P[5] 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[5] 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=1003 means no ;
  73:  !point cloud in ROI ;
  74:  !e.g.: status=1002 means no ;
  75:  !vision results ;
  76:  PAUSE ;

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

sample4

The table below describes the process of switching the parameter recipe in the Mech-Vision project. You can click the hyperlink to the command name to view its detailed description.

Feature Code and description

Switch Mech-Vision Parameter Recipe

  20:  !switch recipe of NO.1 ;
  21:  !Mech-Vision project, ;
  22:  !"MM_SET_MOD(Proj_num,Model_num)" ;
  23:  CALL MM_SET_MOD(1,1) ;
  • MM_SET_MOD: The command to switch the Mech-Vision parameter recipe.

  • First 1: The Mech-Vision project ID.

  • Second1: The ID of the parameter recipe in the Mech-Vision project.

In this entire statement, the parameter recipe of the Mech-Vision project whose ID is 1 is switched to recipe 1.

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.