FANUC Example Program

This topic introduces the example programs provided with Mech-Mind Software Suite and the operations required to perform an actual pick-and-place task.

Three example programs are provided:

The sample programs are stored in xxx\Mech-Mind Software Suite-x.x.x\Mech-Center\Robot_Interface\FANUC\sample.

Before running the program, please make sure that:

  • You have set up Standard Interface communication with the robot.

  • You have completed the hand-eye calibration with the calibration program.

  • Mech-Vision and Mech-Viz projects are created and set to autoload.

  • The TCP has been correctly specified.

  • The robot velocity is set to a low value, so that the operator can notice any unexpected behavior before accidents occur.

Obtain Vision Result from Mech-Vision

 1:  !FUNCTION:Eye to Hand simple pick ;
 2:  !MechMind,2022-05-30 ;
 3:   ;
 4:  !SET Tool ;
 5:  UTOOL_NUM=1 ;
 6:  !Move to HOME Position ;
 7:J P[1] 100% FINE    ;
 8:  !Move to Camera capture Position ;
 9:L P[2] 3000mm/sec FINE    ;
10:  !Set IP address and Port ;
11:  CALL MM_INIT_SKT('8','192.168.1.20',50000,1) ;
12:  WAIT    .10(sec) ;
13:  !Set Vision Recipe ;
14:  //CALL MM_SET_MOD(1,1) ;
15:  !Run Vision Project ;
16:  CALL MM_START_VIS(1,1,2,10) ;
17:  WAIT   1.00(sec) ;
18:  CALL MM_GET_VIS(1,50,51,52) ;
19:  IF (R[52]<>1100) THEN ;
20:  PAUSE ;
21:  ENDIF ;
22:  CALL MM_GET_POS(1,60,70,80) ;
23:L PR[60] 800mm/sec CNT100 Offset,PR[1]    ;
24:L PR[60] 800mm/sec FINE    ;
25:  !Add object grasping logic here ;
26:   ;
27:L PR[60] 800mm/sec CNT100 Offset,PR[1]    ;
28:  !Add transition point ;
29:L P[3] 800mm/sec FINE    ;
30:  !Move to DROP Position ;
31:L P[4] 800mm/sec CNT100 Offset,PR[2]    ;
32:L P[4] 200mm/sec FINE    ;
33:  !Add object releasing logic here ;
34:   ;
35:L P[4] 800mm/sec CNT100 Offset,PR[2]    ;
36:  !Move to HOME Position ;
37:J P[1] 100% FINE    ;

Program Logic

  1. Move the robot to HOME position.

  2. Move the robot to the image-capturing pose.

  3. Initialize communication with MM_INIT_SKT. For detailed information, please refer to FANUC Standard Interface Commands.

  4. If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_SET_MOD. For detailed information, please refer to FANUC Standard Interface Commands.

  5. Run the Mech-Vision project with MM_START_VIS.

  6. Wait for 1 second. Under Eye-In-Hand, this WAIT instruction is required to make sure the robot stays still until image acquisition is completed. Under Eye-To-Hand, this WAIT instruction is not needed if there is a motion procedure between MM_START_VIS and MM_GET_VIS.

  7. Obtain the vision point from Mech-Vision.

  8. Check if the returned status code indicates any error. If an error code is returned, the program is paused.

  9. Store the obtained vision pose (picking pose) to register P[60] with MM_GET_POS.

  10. Move the robot to the picking pose and perform picking.

  11. Move the robot to an intermediate point between the picking pose and placing pose.

  12. Move the robot to the set placing pose and perform placing.

  13. Return the robot to HOME position.

The following parts should be modified according to your actual needs.

Define HOME position

Please set the HOME position in register P[1].

Define the TCP

The TCP in this example is defined as UTOOL_NUM=1. Please change the value 1 according to the actual TCP values.

Teach the image-capturing pose

Please record the image-capturing pose in register P[2].

Teach the Intermediate Point(s)

Intermediate points are between the picking pose and placing pose and are used to ensure that the robot doesn’t collide with the surrounding when moving between the picking and placing poses.

The intermediate points in this example are saved in P[3]. You can add one or more intermediate points.

Teach the Placing Pose

Please record the placing pose in register P[4].

Define Z-Offset from Picking/Placing Pose

Z-offset distances relative to the tool frame from the picking/placing pose are used to ensure collision doesn’t occur when the robot is approaching or departing the picking/placing pose.

Adjust the following commands according to your actual needs.

  • L PR[60] 800mm/sec CNT100 Offset,PR[1]: the Z-offset when approaching the picking pose is saved in PR[1].

  • L PR[60] 800mm/sec CNT100 Offset,PR[1]: the Z-offset when departing the picking pose is saved in register PR[1].

  • L P[4] 800mm/sec CNT100 Offset,PR[2]: the Z-offset when approaching the placing pose is saved in register PR[2].

  • L P[4] 800mm/sec CNT100 Offset,PR[2]: the Z-offset when departing the placing pose is saved in register PR[2].

Add Object Grasping and Releasing Logics

Add logic for controlling the tool action when picking or placing the object.

Obtain Planned Path from Mech-Viz

 1:  !FUNCTION:Eye to Hand simple pick ;
 2:  !and place with Mech-Viz ;
 3:  !MechMind,2022-05-30 ;
 4:   ;
 5:  !SET Tool ;
 6:  UTOOL_NUM=1 ;
 7:  !Move to HOME Position ;
 8:J P[1] 100% FINE    ;
 9:  !Move to Camera capture Position ;
10:L P[2] 3000mm/sec FINE    ;
11:  !Set IP address and Port ;
12:  CALL MM_INIT_SKT('8','192.168.1.20',50000,1) ;
13:  WAIT    .10(sec) ;
14:  !Set Vision Recipe ;
15:  //CALL MM_SET_MOD(1,1) ;
16:  !Run Viz Project ;
17:  CALL MM_START_VIZ(1,10) ;
18:  WAIT    .10(sec) ;
19:  !set branch exitport ;
20:  //CALL MM_SET_BCH(1,1) ;
21:  !get planned path ;
22:  CALL MM_GET_VIZ(2,50,51,52,53) ;
23:  IF (R[53]<>2100) THEN ;
24:  PAUSE ;
25:  ENDIF ;
26:  CALL MM_GET_POS(1,60,70,80) ;
27:  CALL MM_GET_POS(2,61,71,81) ;
28:  CALL MM_GET_POS(3,62,72,82) ;
29:  !follow the planned path to pick ;
30:L PR[60] R[80]mm/sec FINE    ;
31:L PR[61] R[81]mm/sec FINE    ;
32:  !Add object grasping logic here ;
33:   ;
34:L PR[62] R[82]mm/sec FINE    ;
35:  !Add transition point ;
36:L P[3] 800mm/sec FINE    ;
37:  !Move to DROP Position ;
38:L P[4] 800mm/sec CNT100 Offset,PR[2]    ;
39:L P[4] 200mm/sec FINE    ;
40:  !Add object releasing logic here ;
41:   ;
42:L P[4] 800mm/sec CNT100 Offset,PR[2]    ;
43:  !Move to HOME Position ;
44:J P[1] 100% FINE    ;

Program Logic

  1. Move the robot to HOME position.

  2. Move the robot to the image-capturing pose.

  3. Initialize communication with MM_INIT_SKT. For detailed information, please refer to FANUC Standard Interface Commands.

  4. If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_SET_MOD.

  5. Run the Mech-Viz project with MM_START_VIZ.

  6. Obtain the planned path from Mech-Viz.

  7. Check if the returned status code indicates any error. If an error code is returned, the program is paused.

  8. Store obtained waypoint poses in the planned path to PR[60], PR[61], and PR[62]. For detailed information, please refer to FANUC Standard Interface Commands.

  9. Move the robot along the planned path and perform picking.

  10. Move the robot to an intermediate point between the picking pose and placing pose.

  11. Move the robot to the set placing pose and perform placing.

  12. Return the robot to HOME position.

The following parts should be modified according to your actual needs.

Define HOME position

Please set the HOME position in register P[1].

Define the TCP

The TCP in this example is defined as UTOOL_NUM=1. Please change the value 1 according to the actual TCP values.

Teach the image-capturing pose

Please record the image-capturing pose in register P[2].

Teach the Intermediate Point(s)

Intermediate points are between the picking pose and placing pose and are used to ensure that the robot doesn’t collide with the surrounding when moving between the picking and placing poses.

The intermediate points in this example are saved in P[3]. You can add one or more intermediate points.

Teach the Placing Pose

Please record the placing pose in register P[4].

Add Object Grasping and Releasing Logics

Add logic for controlling the tool action when picking or placing the object.

Obtain Planned Path from Mech-Vision

 1:  !FUNCTION:Eye to Hand simple pick ;
 2:  !and place with Mech-Vision Path ;
 3:  !Planning Step ;
 4:  !MechMind,2023-01-10 ;
 5:   ;
 6:  !SET Tool ;
 7:  UTOOL_NUM=1 ;
 8:  !Move to HOME Position ;
 9:J P[1] 100% FINE    ;
10:  !Move to Camera capture Position ;
11:L P[2] 3000mm/sec FINE    ;
12:  !Set IP address and Port ;
13:  CALL MM_INIT_SKT('8','192.168.1.20',50000,1) ;
14:  WAIT    .10(sec) ;
15:  !Set Vision Recipe ;
16:  //CALL MM_SET_MOD(1,1) ;
17:  !Run Vision Project ;
18:  CALL MM_START_VIS(1,1,2,10) ;
19:  WAIT   1.00(sec) ;
20:  CALL MM_GET_VISP(1,2,50,51,52,53) ;
21:  IF (R[53:status]<>1103) THEN ;
22:  PAUSE ;
23:  ENDIF ;
24:  FOR R[100:i]=1 TO R[51:pos_num] ;
25:  R[101:preg no]=59+R[100:i]    ;
26:  R[102:lbl no]=69+R[100:i]    ;
27:  R[103:spd no]=79+R[100:i]    ;
28:  CALL MM_GET_POS(R[100:i],R[101:preg no],R[102:lbl no],R[103:spd no]) ;
29:  ENDFOR ;
30:  !follow the planned path to pick ;
31:  FOR R[110:j]=1 TO R[51:pos_num] ;
32:  R[111:preg]=59+R[110:j]    ;
33:  R[112:spd]=79+R[110:j]    ;
34:L PR[R[111]] R[R[112]]mm/sec FINE    ;
35:  IF (R[110:j]=R[52:vpos_num]) THEN ;
36:  PAUSE ;
37:  !Add object grasping logic here ;
38:  ENDIF ;
39:  ENDFOR ;
40:  !Add transition point ;
41:L P[3] 800mm/sec FINE    ;
42:  !Move to DROP Position ;
43:L P[4] 800mm/sec CNT100 Offset,PR[2]    ;
44:L P[5] 200mm/sec FINE    ;
45:  !Add object releasing logic here ;
46:   ;
47:L P[6] 800mm/sec CNT100 Offset,PR[2]    ;
48:  !Move to HOME Position ;
49:J P[7] 100% FINE    ;

Program Logic

  1. Move the robot to HOME position.

  2. Move the robot to the image-capturing pose.

  3. Initialize communication with MM_INIT_SKT. For detailed information, please refer to FANUC Standard Interface Commands.

  4. If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_SET_MOD.

  5. Run the Mech-Vision project with MM_START_VIS.

  6. Obtain the planned path from Mech-Vision with MM_GET_VISP.

  7. Check if the returned status code indicates any error. If an error code is returned, the program is paused.

  8. Store obtained waypoint poses in the planned path to PR[60] and consecutive position registers with a FOR loop. Please refer to FANUC Standard Interface Commands.

  9. Move the robot along the planned path with a FOR loop and perform picking.

  10. Move the robot to an intermediate point between the picking pose and placing pose.

  11. Move the robot to the set placing pose and perform placing.

  12. Return the robot to HOME position.

The following parts should be modified according to your actual needs.

Define HOME position

Please set the HOME position in register P[1].

Define the TCP

The TCP in this example is defined as UTOOL_NUM=1. Please change the value 1 according to the actual TCP values.

Teach the image-capturing pose

Please record the image-capturing pose in register P[2].

Teach the Intermediate Point(s)

Intermediate points are between the picking pose and placing pose and are used to ensure that the robot doesn’t collide with the surrounding when moving between the picking and placing poses.

The intermediate points in this example are saved in P[3]. You can add one or more intermediate points.

Teach the Placing Pose

Please record the placing pose in register P[4].

Add Object Grasping and Releasing Logics

Add logic for controlling the tool action when picking or placing the object.