Example Program 14: MM_S14_Vis_GetUserData

Program Introduction

Description

When the robot obtains the vision result, the robot also obtains the custom output data from the Mech-Vision project.

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

Project

Mech-Vision project (one or more custom ports needed to be added to the Output Step)

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

Compared with the MM_S1_Vis_Basic example program, this example program contains only the following modification (the code of this modification is bolded). As such, only the modification is described in the following part. For information about the parts of MM_S14_Vis_GetUserData 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 and get vision result ;
   4:  !and custom data using ;
   5:  !command 110 ;
   6:  !Mech-Mind, 2023-12-25 ;
   7:  !-------------------------------- ;
   8:   ;
   9:  !set current uframe NO. to 0 ;
  10:  UFRAME_NUM=0 ;
  11:  !set current tool NO. to 1 ;
  12:  UTOOL_NUM=1 ;
  13:  !move to robot home position ;
  14:J P[1] 100% FINE    ;
  15:  !initialize communication ;
  16:  !parameters(initialization is ;
  17:  !required only once) ;
  18:  CALL MM_INIT_SKT('8','127.0.0.1',50000,5) ;
  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 vision result from NO.1 ;
  24:  !Mech-Vision project ;
  25:  CALL MM_GET_DY_DT(1,51,53) ;
  26:  !check whether vision result has ;
  27:  !been got from Mech-Vision ;
  28:  !successfully ;
  29:  IF R[53]<>1100,JMP LBL[99] ;
  30:  !save first vision point data to ;
  31:  !local variables ;
  32:  CALL MM_GET_DYPOS(1,60,70,90) ;
  33:  !save received custom data ;
  34:  R[10]=R[90]    ;
  35:  R[11]=R[91]    ;
  36:  R[12]=R[92]    ;
  37:  !move to intermediate waypoint ;
  38:  !of picking ;
  39:J P[3] 50% CNT100    ;
  40:  !move to approach waypoint ;
  41:  !of picking ;
  42:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  43:  !move to picking waypoint ;
  44:L PR[60] 300mm/sec FINE    ;
  45:  !add object grasping logic here, ;
  46:  !such as "DO[1]=ON" ;
  47:  PAUSE ;
  48:  !move to departure waypoint ;
  49:  !of picking ;
  50:L PR[60] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  51:  !move to intermediate waypoint ;
  52:  !of placing ;
  53:J P[4] 50% CNT100    ;
  54:  !move to approach waypoint ;
  55:  !of placing ;
  56:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  57:  !move to placing waypoint ;
  58:L P[5] 300mm/sec FINE    ;
  59:  !add object releasing logic here, ;
  60:  !such as "DO[1]=OFF" ;
  61:  PAUSE ;
  62:  !move to departure waypoint ;
  63:  !of placing ;
  64:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  65:  !move back to robot home position ;
  66:J P[1] 100% FINE    ;
  67:  END ;
  68:   ;
  69:  LBL[99:vision error] ;
  70:  !add error handling logic here ;
  71:  !according to different ;
  72:  !error codes ;
  73:  !e.g.: status=1003 means no ;
  74:  !point cloud in ROI ;
  75:  !e.g.: status=1002 means no ;
  76:  !vision results ;
  77:  PAUSE ;

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

sample14

The table below describes the bolded code. You can click the hyperlink to the command name to view its detailed description.

Feature Code and description

Obtain the vision result (including the custom data)

  23:  !get vision result from NO.1 ;
  24:  !Mech-Vision project ;
  25:  CALL MM_GET_DY_DT(1,51,53) ;
For a Mech-Vision project, custom data refers to the data output by the custom ports of the Mech-Vision project.
  • MM_GET_DY_DT: The command to obtain the vision result. The vision points obtained by this command contain custom output data in addition to poses and labels, while the vision points obtained by MM_GET_VIS command do not contain custom output data.

  • 1: The Mech-Vision project ID.

  • 51: The numeric register R[51], which stores the number of vision points returned by the vision system.

  • 53: The numeric register R[53], which stores the command execution status code.

The entire statement indicates that the robot obtains the vision result from the Mech-Vision project with an ID of 1. The vision result includes custom data.

The returned vision result is saved to the robot memory and cannot be directly obtained. To access the custom data in the vision result, you must store the vision result in a subsequent step.

Store the vision result (including the custom data)

  30:  !save first vision point data to ;
  31:  !local variables ;
  32:  CALL MM_GET_DYPOS(1,60,70,90) ;
  • MM_GET_DYPOS: The command to store the vision result. This command stores custom data in addition to poses and labels. However, MM_GET_POS can store only poses, labels and tool IDs and cannot store custom data. In addition, MM_GET_DYPOS saves the custom data of vision points that was stored in the robot memory to the specified register.

  • 1: The first vision point is stored.

  • 60: The position register PR[60], which stores the TCP of the first vision point, i.e., the TCP of the picking waypoint.

  • 70: The numeric register R[70], which stores the label of the first vision point.

  • 90: Numeric registers starting from R[90]. The custom data for the first vision point will be sequentially stored in registers starting from numeric register R[90].

The entire statement stores the TCP, label, and custom data of the first vision point in the specified registers.

  33:  !save received custom data ;
  34:  R[10]=R[90]    ;
  35:  R[11]=R[91]    ;
  36:  R[12]=R[92]    ;

The above code assigns the three pieces of custom data of the vision point (picking waypoint) in R[90], R[91], and R[92] to R[10], R[11], and R[12], respectively.

You can define the meaning of R[10], R[11], and R[12]. For example, the values in R[10], R[11], and R[12] could represent the robot’s offsets along the XYZ axes when moving to the picking waypoint.

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.