Sample Program 22: MM_S22_Vis_As_Uframe

You are currently viewing the documentation for a pre-release version (2.2.0). To access documentation for other versions, click the "Switch Version" button located in the upper-right corner of the page.

■ If you're unsure about the version of the product you are using, please contact Mech-Mind Technical Support for assistance.

Program Introduction

Function description

The robot triggers the Mech-Vision project to run and obtain vision results, uses the result as a coordinate system, and performs the pick-and-place workflow.

File path

Under the installation directory of Mech-Vision and Mech-Viz: Communication Component/Robot_Interface/FANUC/sample/MM_S22_Vis_As_Uframe.

Required project

Mech-Vision project

Prerequisites

  1. Standard interface communication has been configured in Set up Standard Interface Communication with FANUC.

  2. Automatic calibration has been completed in FANUC Automatic Calibration.

This sample program is for reference only. Modify it according to your actual situation. Do not use it directly.

Program Explanation

The following shows the code of the MM_S22_Vis_As_Uframe sample program and related explanations.

Compared with the MM_S3_Vis_Path sample, this sample only adds the function of using the obtained result as a user frame to perform the pick-and-place process (the bold code). Therefore, the following content does not repeat the explanation of the code parts identical to MM_S3_Vis_Path (for details, see MM_S3_Vis_Path sample description).
   1:  !-------------------------------- ;
   2:  !FUNCTION: trigger Mech-Vision ;
   3:  !project and get vision result ;
   4:  !as the uframe 7 ;
   5:  !Mech-Mind, 2026-1-23 ;
   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','192.168.1.20',30000,5) ;
  18:  !move to image-capturing position ;
  19:L P[2] 1000mm/sec FINE    ;
  20:  !trigger NO.1 Mech-Vision project ;
  21:  CALL MM_START_VIS(1,0,2,10,53) ;
  22:  !check whether vision project has ;
  23:  !been triggered successfully ;
  24:  IF (R[53]<>1102),JMP LBL[99] ;
  25:  !get vision result from NO.1 ;
  26:  !Mech-Vision project ;
  27:  CALL MM_GET_VIS(1,51,53) ;
  28:  !check whether vision result has ;
  29:  !been got from Mech-Vision ;
  30:  !successfully ;
  31:  IF (R[53]<>1100),JMP LBL[99] ;
  32:  !save first vision point data to ;
  33:  !local variables ;
  34:  CALL MM_GET_POS(1,60,70,80) ;
  35:  !move to intermediate waypoint ;
  36:  !of picking ;
  37:J P[3] 50% CNT100    ;
  38:   ;
  39:  !set the uframe for camera ;
  40:  UFRAME[7]=PR[60] ;
  41:  UFRAME_NUM=7 ;
  42:   ;
  43:  !move to approach waypoint ;
  44:  !of picking ;
  45:L P[6] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  46:  !move to picking waypoint ;
  47:L P[6] 300mm/sec FINE    ;
  48:  !add object grasping logic here, ;
  49:  !such as "DO[1]=ON" ;
  50:  PAUSE ;
  51:  !move to departure waypoint ;
  52:  !of picking ;
  53:L P[6] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  54:   ;
  55:  !change the uframe ;
  56:  UFRAME_NUM=0 ;
  57:   ;
  58:  !move to intermediate waypoint ;
  59:  !of placing ;
  60:J P[4] 50% CNT100    ;
  61:  !move to approach waypoint ;
  62:  !of placing ;
  63:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  64:  !move to placing waypoint ;
  65:L P[5] 300mm/sec FINE    ;
  66:  !add object releasing logic here, ;
  67:  !such as "DO[1]=OFF" ;
  68:  PAUSE ;
  69:  !move to departure waypoint ;
  70:  !of placing ;
  71:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  72:  !move back to robot home position ;
  73:J P[1] 100% FINE    ;
  74:  END ;
  75:   ;
  76:  LBL[99:handling error] ;
  77:  !add error handling logic here ;
  78:  !according to different ;
  79:  !error codes ;
  80:  !e.g.: mm_status=1003 means no ;
  81:  !point cloud in ROI ;
  82:  !e.g.: mm_status=1002 means no ;
  83:  !vision results ;
  84:  !e.g.: mm_status=3099 means ;
  85:  !failed to open socket ;
  86:  PAUSE ;

The workflow corresponding to the sample program code above is shown in the following figure.

The following table explains the logic of the added function. Click the hyperlink of a command to view its detailed description.

Workflow Code and description

Set the vision user frame

  39:  !set the uframe for camera ;
  40:  UFRAME[7]=PR[60] ;
  41:  UFRAME_NUM=7 ;
  • Line 40: Assign the pose PR[60] identified by vision to user frame 7 (the dedicated vision frame).

  • Line 41: Activate user frame 7, so subsequent picking is based on the vision coordinate system.

  55:  !change the uframe ;
  56:  UFRAME_NUM=0 ;
  • Switch back to the default user frame before moving to the place transition point P[4].

Pick and place

  35:  !move to intermediate waypoint ;
  36:  !of picking ;
  37:J P[3] 50% CNT100    ;
  38:   ;
  39:  !set the uframe for camera ;
  40:  UFRAME[7]=PR[60] ;
  41:  UFRAME_NUM=7 ;
  42:   ;
  43:  !move to approach waypoint ;
  44:  !of picking ;
  45:L P[6] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  46:  !move to picking waypoint ;
  47:L P[6] 300mm/sec FINE    ;
  48:  !add object grasping logic here, ;
  49:  !such as "DO[1]=ON" ;
  50:  PAUSE ;
  51:  !move to departure waypoint ;
  52:  !of picking ;
  53:L P[6] 1000mm/sec FINE Tool_Offset,PR[1]    ;
  54:   ;
  55:  !change the uframe ;
  56:  UFRAME_NUM=0 ;
  57:   ;
  58:  !move to intermediate waypoint ;
  59:  !of placing ;
  60:J P[4] 50% CNT100    ;
  61:  !move to approach waypoint ;
  62:  !of placing ;
  63:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  64:  !move to placing waypoint ;
  65:L P[5] 300mm/sec FINE    ;
  66:  !add object releasing logic here, ;
  67:  !such as "DO[1]=OFF" ;
  68:  PAUSE ;
  69:  !move to departure waypoint ;
  70:  !of placing ;
  71:L P[5] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  72:  !move back to robot home position ;
  73:J P[1] 100% FINE    ;
  74:  END ;

The preceding code means that the robot first switches to the vision-matched user frame to complete the picking operation, then switches back to the default frame to perform the placing operation, and finally returns to the origin to end the program. UFRAME[7]=PR[60] assigns the pose data obtained by vision recognition to user frame 7, and UFRAME_NUM=7 activates this vision frame so that subsequent pick actions are executed based on the vision-recognized workpiece position. After picking is completed, UFRAME_NUM=0 switches back to the robot base frame to ensure that placing is executed based on the preset reference position. Tool_Offset,PR[1] and Tool_Offset,PR[2] are tool offset parameters for picking and placing respectively, used to control safe offset when the robot end approaches or leaves the workpiece and to avoid collision.

Is this page helpful?

You can give a feedback in any of the following ways:

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.