Example Program 10: MM_S10_Viz_Subtask

Program Introduction

Description

This example program consists of two programs. The secondary program triggers the Mech-Viz project to run to obtain the planned path. The primary program moves the robot based on the planned path. Then, the primary program triggers the secondary program to run when the robot leaves the picking area to obtain the next planned path, shortening the cycle time.

This example is very similar to the MM_S8_Viz_Subtask example program, except that the timing of the primary program to trigger the secondary program is different. It is recommended that you compare the two examples to better understand their nuances.

File path

Secondary program: 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_S10_Sub path.

Primary program: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_S10_Viz_Subtask path.

Project

Mech-Vision and Mech-Viz projects

Prerequisites

This example program is provided for reference only. Before using the program, please modify the program according to the actual scenario.

Program Description

The following part describes the secondary program.

Similar to the MM_S2_Viz_Basic example program, the secondary program triggers the Mech-Viz project to run and obtains the planned path. As such, the features of the secondary program that are similar to those of MM_S2_Viz_Basic are not described in this part. For more information about these features, see Example Program 2: MM_S2_Viz_Basic.
   1:  !-------------------------------- ;
   2:  !FUNCTION: run Mech-Viz project ;
   3:  !and get planned path in subtask ;
   4:  !(run together with ;
   5:  !MM_S10_Viz_Subtask) ;
   6:  !Mech-Mind, 2023-12-25 ;
   7:  !-------------------------------- ;
   8:   ;
   9:  F[11]=(ON) ;
  10:  !trigger Mech-Viz project ;
  11:  CALL MM_START_VIZ(2,10) ;
  12:  !get planned path, 1st argument ;
  13:  !(1) means getting pose in JPs ;
  14:  CALL MM_GET_VIZ(1,51,52,53) ;
  15:  !check whether planned path has ;
  16:  !been got from Mech-Viz ;
  17:  !successfully ;
  18:  IF (R[53]=2100) THEN ;
  19:  !save waypoints of the planned ;
  20:  !path to local variables one ;
  21:  !by one ;
  22:  CALL MM_GET_JPS(1,60,70,80) ;
  23:  CALL MM_GET_JPS(2,61,71,81) ;
  24:  CALL MM_GET_JPS(3,62,72,82) ;
  25:  ENDIF ;
  26:  F[11]=(OFF) ;

The above code indicates that if the secondary program is running, the following operations are performed.

  1. Set F[11] to ON.

  2. Run the Mech-Viz project.

  3. Obtain the planned path.

  4. Store the planned path.

  5. Set F[11] to OFF.

As such, you can determine if the secondary program finishes running based on the F[11] value.

The following part describes the primary program.

Similar to the MM_S2_Viz_Basic example program, the primary program performs picking and placing based on the planned path. As such, the features of the primary program that are similar to those of MM_S2_Viz_Basic are not described in this part. For more information about these features, see Example Program 2: MM_S2_Viz_Basic.
   1:  !-------------------------------- ;
   2:  !FUNCTION: run Mech-Viz project ;
   3:  !and get planned path in subtask ;
   4:  !(run together with ;
   5:  !MM_S10_Sub) ;
   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:  !initialize communication ;
  14:  !parameters(initialization is ;
  15:  !required only once) ;
  16:  CALL MM_INIT_SKT('8','127.0.0.1',50000,5) ;
  17:  !move to robot home position ;
  18:J P[1] 100% FINE    ;
  19:  RUN MM_S10_SUB ;
  20:  LBL[1:LOOP] ;
  21:  !move to wait position for ;
  22:  !picking ;
  23:L P[2] 1000mm/sec FINE    ;
  24:  !wait until subtask program ;
  25:  !finished ;
  26:  WAIT (F[11]=OFF)    ;
  27:  !check whether planned path has ;
  28:  !been got from Mech-Viz ;
  29:  !successfully ;
  30:  IF R[53]<>2100,JMP LBL[99] ;
  31:  !follow the planned path to pick ;
  32:  !move to approach waypoint ;
  33:  !of picking ;
  34:J PR[60] 50% FINE    ;
  35:  !move to picking waypoint ;
  36:J PR[61] 10% FINE    ;
  37:  !add object grasping logic here, ;
  38:  !such as "DO[1]=ON" ;
  39:  PAUSE ;
  40:  !move to departure waypoint ;
  41:  !of picking ;
  42:J PR[62] 50% FINE    ;
  43:  !move to intermediate waypoint ;
  44:  !of placing, and trigger Mech-Viz ;
  45:  !project and get planned path in ;
  46:  !advance ;
  47:J P[3] 50% CNT100 DB   10.0mm,CALL MM_S10_SUB    ;
  48:  !move to approach waypoint ;
  49:  !of placing ;
  50:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  51:  !move to placing waypoint ;
  52:L P[4] 300mm/sec FINE    ;
  53:  !add object releasing logic here, ;
  54:  !such as "DO[1]=OFF" ;
  55:  PAUSE ;
  56:  !move to departure waypoint ;
  57:  !of placing ;
  58:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  59:  !move back to robot home position ;
  60:J P[1] 100% FINE    ;
  61:  JMP LBL[1] ;
  62:  END ;
  63:   ;
  64:  LBL[99:vision error] ;
  65:  !add error handling logic here ;
  66:  !according to different ;
  67:  !error codes ;
  68:  !e.g.: status=2038 means no ;
  69:  !point cloud in ROI ;
  70:  PAUSE ;

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

sample10

The table below illustrates the core code of the primary program.

Feature Code and description

Trigger the Mech-Viz project to run and obtain the planned path

  19:  RUN MM_S10_SUB ;

The above code indicates that the primary program calls the MM_S10_SUB secondary program to trigger the Mech-Viz project to run and obtain the planned path.

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

  20:  LBL[1:LOOP] ;
  ...
  61:  JMP LBL[1] ;

The above code indicates that the primary program repeatedly executes the code at LBL[1].

  21:  !move to wait position for ;
  22:  !picking ;
  23:L P[2] 1000mm/sec FINE    ;
  24:  !wait until subtask program ;
  25:  !finished ;
  26:  WAIT (F[11]=OFF)    ;
  27:  !check whether planned path has ;
  28:  !been got from Mech-Viz ;
  29:  !successfully ;
  30:  IF R[53]<>2100,JMP LBL[99] ;

In the above code, the robot moves to a waiting waypoint before picking and waits for the secondary program to finish running (i.e., F[11] changes from ON to OFF), thus ensuring that the planned path has been obtained and stored.

  31:  !follow the planned path to pick ;
  32:  !move to approach waypoint ;
  33:  !of picking ;
  34:J PR[60] 50% FINE    ;
  35:  !move to picking waypoint ;
  36:J PR[61] 10% FINE    ;
  37:  !add object grasping logic here, ;
  38:  !such as "DO[1]=ON" ;
  39:  PAUSE ;
  40:  !move to departure waypoint ;
  41:  !of picking ;
  42:J PR[62] 50% FINE    ;

In the above example, the robot moves along the planned path to the approach waypoint of picking (PR[60]) and then to the picking waypoint (PR[61]), performs picking (for example, DO[1]=ON), and then moves to the departure waypoint of picking (PR[62]).

  43:  !move to intermediate waypoint ;
  44:  !of placing, and trigger Mech-Viz ;
  45:  !project and get planned path in ;
  46:  !advance ;
  47:J P[3] 50% CNT100 DB   10.0mm,CALL MM_S10_SUB    ;
  • P[3]: The intermediate waypoint during placing. You need to teach the waypoint beforehand.

  • “DB 10.0mm”: Set a spherical radius of 10.0mm around the target point.

  • “CALL MM_S10_SUB”: When the robot reaches the specified spherical radius, it calls the MM_S10_SUB program.

The above code indicates that when the robot enters the spherical area centered on P[3], it calls the MM_S10_SUB secondary program, thereby triggering the Mech-Viz project to run to obtain the planned path. Now that the robot resides outside the area for placing, the robot can plan the next picking path in advance without waiting for the placing to complete and then planning the next picking path.

Please note the difference between this example program and the MM_S8_Viz_Subtask example program. The MM_S8_Viz_Subtask example program calls the secondary program before the robot moves to the placing waypoint, while this example program calls the secondary program after the robot leaves the picking area.
  48:  !move to approach waypoint ;
  49:  !of placing ;
  50:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  51:  !move to placing waypoint ;
  52:L P[4] 300mm/sec FINE    ;
  53:  !add object releasing logic here, ;
  54:  !such as "DO[1]=OFF" ;
  55:  PAUSE ;
  56:  !move to departure waypoint ;
  57:  !of placing ;
  58:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  59:  !move back to robot home position ;
  60:J P[1] 100% FINE    ;

The above example indicates that the robot moves to the approach waypoint of placing (Tool_Offset,PR[2]) and then to the placing waypoint (P[4]), performs placing (such as DO[1]=OFF), and then moves to the departure waypoint of placing (Tool_Offset,PR[2]) and then to 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.