FANUC Robot Communication Program Guide
|
Overview of Communication Logic
For the detailed interface communication flow and command specification, see Interface Communication Command Description.
Loading the Robot Programs
| Before importing the communication programs, it is strongly recommended to make a full backup of all existing robot programs to avoid data loss. |
Program Package
Use the official FANUC Vision Standard Programs to install the vision communication functions. This package contains all required PC and TP programs for integrating with the EpicPro software and can be loaded directly on the FANUC controller.
Loading Steps (Summary)
-
Switch the device to the USB storage where the program package is located.
-
Navigate to the target folder (PC and TP program folders) and ensure the path does not contain Chinese characters or spaces.
-
Load all PC programs, then load all TP programs.
-
Finally, check the program list to confirm that all required PC/TP programs have been imported successfully.
Robot Interface Commands
Standard Commands
Trigger Image Capture
TF_Trigger ( String CAMERA_ID )
// Parameter: CAMERA_ID - string camera ID, such as "0";
// to trigger two cameras in the same workspace, you can pass "0,1".
// Function: Sends command 110 with CAMERA_ID to trigger capture.
Switch Object in Workspace
TF_SwitchSpace ( INT spaceId , INT objectId )
// Parameters: spaceId - workspace ID; objectId - grasp configuration ID.
// Function: Sends 130, spaceId, objectId to switch the active object.
Robot Capture Pose (Eye-in-Hand)
TF_EIH_SetPose ( String CAMERA_ID )
// Parameter: CAMERA_ID - string camera ID.
// Function: In eye-in-hand scenarios, sends 140, CAMERA_ID, current robot capture pose.
Detection (No Retreat Path)
TF_Detector ( INT VisionPoseNum )
// Parameter: VisionPoseNum - required number of vision poses / grasp points.
// Function: Triggers detection and sends 120 with grasp count and 0 for retreat count.
Detection with Retreat Path
TF_RetreatDetector ( INT GraspCount , INT RetreatCount )
// Parameters: GraspCount - number of grasp path points;
// RetreatCount - number of retreat path points.
// Function: Triggers detection and sends 120 with grasp path count and retreat path count.
Quick Commands
Quick Detection (No Retreat Path)
TF_FastDetector ( INT VisionPoseNum )
// Parameter: VisionPoseNum - required number of vision poses / grasp points.
// Function: Triggers detection and sends 220 with grasp count and 0 for retreat count.
Quick Detection with Retreat Path
TF_FastRetreatDetector ( INT GraspCount , INT RetreatCount )
// Parameters: GraspCount - number of grasp path points;
// RetreatCount - number of retreat path points.
// Function: Triggers detection and sends 220 with grasp path count and retreat path count.
Capture + Robot Capture Pose (Eye-in-Hand)
TF_EIH_FastTrigger ( String CAMERA_ID )
// Parameter: CAMERA_ID - string camera ID.
// Function: In eye-in-hand scenarios, sends 240, CAMERA_ID, current robot capture pose.
Capture + Robot Capture Pose + Detection (Eye-in-Hand)
TF_EIH_FastDetector ( String CAMERA_ID , INT VisionPoseNum )
// Parameters: CAMERA_ID - string camera ID; VisionPoseNum - required number of vision poses.
// Function: In eye-in-hand scenarios, sends 250 to quickly trigger detection.
Capture + Robot Capture Pose + Detection with Retreat Path (Eye-in-Hand)
TF_EIH_FastRetreatDetector ( String CAMERA_ID , INT GraspCount , INT RetreatCount )
// Parameters: CAMERA_ID - string camera ID;
// GraspCount, RetreatCount - number of approach and retreat path points.
// Function: In eye-in-hand scenarios, sends 250 to quickly trigger detection with approach + retreat paths.
Switch Object in Workspace + Capture
TF_FastSwitch ( INT spaceId , INT objectId , String CAMERA_ID )
// Parameters: spaceId - workspace ID; objectId - grasp configuration ID; CAMERA_ID - string camera ID.
// Function: Sends 310 to quickly switch object and trigger capture.
Switch Object in Workspace + Capture + Detection
TF_FastSwitchDetector ( INT spaceId , INT objectId , String CAMERA_ID , INT VisionPoseNum )
// Parameters: spaceId - workspace ID;
// objectId - grasp configuration ID;
// CAMERA_ID - string camera ID;
// VisionPoseNum - required number of vision poses.
// Function: Sends 320 to quickly switch object + capture + detection.
Switch Object in Workspace + Capture + Detection with Retreat Path
TF_FastSwitchRetreatDetector ( INT spaceId , INT objectId , String CAMERA_ID ,
INT GraspCount , INT RetreatCount )
// Parameters: spaceId - workspace ID;
// objectId - grasp configuration ID;
// CAMERA_ID - string camera ID;
// GraspCount - number of approach path points;
// RetreatCount - number of retreat path points.
// Function: Sends 320 to quickly switch object + capture + detection with approach + retreat paths.
Switch Object in Workspace + Capture + Robot Capture Pose (Eye-in-Hand)
TF_EIH_FastSwitchTrigger ( INT spaceId , INT objectId , String CAMERA_ID )
// Parameters: spaceId - workspace ID; objectId - grasp configuration ID; CAMERA_ID - string camera ID.
// Function: In eye-in-hand scenarios, sends 340 to quickly switch object + capture + robot capture pose.
Switch Object in Workspace + Capture + Robot Capture Pose + Detection (Eye-in-Hand)
TF_EIH_FastSwitchDetector ( INT spaceId , INT objectId , String CAMERA_ID , INT VisionPoseNum )
// Parameters: spaceId - workspace ID;
// objectId - grasp configuration ID;
// CAMERA_ID - string camera ID;
// VisionPoseNum - required number of vision poses.
// Function: In eye-in-hand scenarios, sends 350 to quickly switch object + capture + robot capture pose + detection.
Switch Object in Workspace + Capture + Robot Capture Pose + Detection with Retreat Path (Eye-in-Hand)
TF_EIH_FastSwitchRetreatDetector ( INT spaceId , INT objectId , String CAMERA_ID ,
INT GraspCount , INT RetreatCount )
// Parameters: spaceId - workspace ID;
// objectId - grasp configuration ID;
// CAMERA_ID - string camera ID;
// GraspCount - number of approach path points;
// RetreatCount - number of retreat path points.
// Function: In eye-in-hand scenarios, sends 350 to quickly switch object + capture + robot capture pose + detection with retreat path.
Function API Description
Initialize Communication
TF_INT_SOCKET ( String IP , INT PORT , INT CHANNEL , INT TIMEOUT )
// Parameters: IP - IP address; PORT - port number; CHANNEL - channel index; TIMEOUT - receive timeout.
// Function: Initializes the communication channel.
Upload Calibration Pose
TF_Calibration ()
// Function: Uploads the current robot pose during calibration.
Get EpicPro Data
TF_GETPOSE ( INT PRNUM )
// Parameter: PRNUM - PR register index.
// Function: Retrieves data output from EpicPro into the specified PR.
Sample Programs
Four basic usage scenarios are provided.
Eye-to-Hand, Ordered Pick Scenario
1: CALL TF_INT_SOCKET('192.168.33.66',5700,3,30000) ;// Communication initialization
2: PAUSE ;
3: CALL TF_CON_SOCKET ;// Connect to EpicPro
4: CALL TF_FASTSWITCH(1,1,'1') ;// Switch to space 1, object 1 and trigger capture with camera 1
5: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
6: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
7: PAUSE ;// Add error handling logic here, e.g. re-trigger
8: ENDIF ;
9: CALL TF_DETECTOR(1) ;// Trigger detection; 1 means only one grasp point is required
10: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
11: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
12: PAUSE ;// Add error handling logic here, e.g. re-trigger
13: ENDIF ;
14: UTOOL_NUM=1 ;// Set tool frame
15: UFRAME_NUM=0 ;// Set user frame
16: CALL TF_GETPOSE(10) ;// Get pose into PR[10]
17:L PR[10] 100mm/sec FINE Tool_Offset,PR[5] ;// Offset 100 mm along tool Z using PR[5] as tool offset
18:L PR[10] 100mm/sec FINE ;// Grasp pose
19: CALL TF_CLOSE_SOCKET ;// Close communication (optional; long connections are supported)
Eye-to-Hand, Path Planning Scenario
1: CALL TF_INT_SOCKET('192.168.33.66',5700,3,30000) ;// Communication initialization
2: PAUSE ;
3: CALL TF_CON_SOCKET ;// Connect to EpicPro
4: CALL TF_FASTSWITCH(1,1,'1') ;// Switch to space 1, object 1 and trigger capture with camera 1
5: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
6: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
7: PAUSE ;// Add error handling logic here, e.g. re-trigger
8: ENDIF ;
// Planning case 1: only plan the approach path.
9: CALL TF_DETECTOR(5) ;// Request a grasp path with 5 points; the 5th point is the grasp pose
10: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
11: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
12: PAUSE ;// Add error handling logic here, e.g. re-trigger
13: ENDIF ;
// Planning case 2: plan both approach and retreat paths.
14: CALL TF_RETREATDETECTOR(5,10) ;// Approach path has 5 points, retreat path has 10 points
15: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
16: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
17: PAUSE ;// Add error handling logic here, e.g. re-trigger
18: ENDIF ;
19: UTOOL_NUM=1 ;// Set tool frame
20: UFRAME_NUM=0 ;// Set user frame
21: CALL TF_GETPOSE(10) ;// Get path data into PR[10] and following registers
// Depending on EpicPro configuration, choose Cartesian or joint execution.
// Cartesian:
22: IF (R[32:PoseType]=0) THEN ;
23: FOR R[1]=10 TO 13 ;
24:L PR[R[1]] 100mm/sec CNT100 ;
25: ENDFOR ;
26:L PR[14] 100mm/sec FINE ;
27: PAUSE ;// At the grasp pose; replace with gripper close, etc.
28: FOR R[2]=15 TO 24 ;
29:L PR[R[2]] 100mm/sec CNT100 ;
30: ENDFOR ;
31: ENDIF ;
// Joint-space:
32: IF (R[32:PoseType]=1) THEN ;
33: FOR R[1]=10 TO 13 ;
34:J PR[R[1]] 2% CNT100 ;
35: ENDFOR ;
36:J PR[14] 2% FINE ;
37: PAUSE ;// At the grasp pose; replace with gripper close, etc.
38: FOR R[2]=15 TO 24 ;
39:J PR[R[2]] 2% CNT100 ;
40: ENDFOR ;
41: ENDIF ;
42: CALL TF_CLOSE_SOCKET ;// Close communication (optional)
Eye-in-Hand, Ordered Pick Scenario
1: CALL TF_INT_SOCKET('192.168.33.66',5700,3,30000) ;// Communication initialization
2: PAUSE ;
3: CALL TF_CON_SOCKET ;// Connect to EpicPro
4: CALL TF_EIH_FASTSWITCHTRIGGER(1,1,'1') ;// Switch space/object, send current capture pose, then trigger camera 1
5: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
6: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
7: PAUSE ;// Add error handling logic here, e.g. re-trigger
8: ENDIF ;
9: CALL TF_DETECTOR(1) ;// Trigger detection; 1 means only one grasp point is required
10: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
11: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
12: PAUSE ;// Add error handling logic here, e.g. re-trigger
13: ENDIF ;
14: UTOOL_NUM=1 ;// Set tool frame
15: UFRAME_NUM=0 ;// Set user frame
16: CALL TF_GETPOSE(10) ;
17:L PR[10] 100mm/sec FINE Tool_Offset,PR[5] ;// Offset 100 mm along tool Z using PR[5] as tool offset
18:L PR[10] 100mm/sec FINE ;// Grasp pose
19: CALL TF_CLOSE_SOCKET ;// Close communication (optional)
Eye-in-Hand, Path Planning Scenario
1: CALL TF_INT_SOCKET('192.168.33.66',5700,3,30000) ;// Communication initialization
2: PAUSE ;
3: CALL TF_CON_SOCKET ;// Connect to EpicPro
4: CALL TF_EIH_FASTSWITCHTRIGGER(1,1,'1') ;// Switch space/object, send current capture pose, then trigger camera 1
5: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
6: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
7: PAUSE ;// Add error handling logic here, e.g. re-trigger
8: ENDIF ;
// Planning case 1: only plan the approach path.
9: CALL TF_DETECTOR(5) ;// Request a grasp path with 5 points; the 5th point is the grasp pose
10: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
11: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
12: PAUSE ;// Add error handling logic here, e.g. re-trigger
13: ENDIF ;
// Planning case 2: plan both approach and retreat paths.
14: CALL TF_RETREATDETECTOR(5,10) ;// Approach path has 5 points, retreat path has 10 points
15: CALL TF_GETSTATUS(30) ;// Get status of previous EpicPro command
16: IF (R[31:Command]=0) THEN ;// If status is abnormal, handle accordingly
17: PAUSE ;// Add error handling logic here, e.g. re-trigger
18: ENDIF ;
19: UTOOL_NUM=1 ;
20: UFRAME_NUM=0 ;
21: CALL TF_GETPOSE(10) ;// Get path data into PR[10] and following registers
// Depending on EpicPro configuration, choose Cartesian or joint execution.
// Cartesian:
22: IF (R[32:PoseType]=0) THEN ;
23: FOR R[1]=10 TO 13 ;
24:L PR[R[1]] 100mm/sec CNT100 ;
25: ENDFOR ;
26:L PR[14] 100mm/sec FINE ;
27: PAUSE ;// At the grasp pose; replace with gripper close, etc.
28: FOR R[2]=15 TO 24 ;
29:L PR[R[2]] 100mm/sec CNT100 ;
30: ENDFOR ;
31: ENDIF ;
// Joint-space:
32: IF (R[32:PoseType]=1) THEN ;
33: FOR R[1]=10 TO 13 ;
34:J PR[R[1]] 2% CNT100 ;
35: ENDFOR ;
36:J PR[14] 2% FINE ;
37: PAUSE ;// At the grasp pose; replace with gripper close, etc.
38: FOR R[2]=15 TO 24 ;
39:J PR[R[2]] 2% CNT100 ;
40: ENDFOR ;
41: ENDIF ;
42: CALL TF_CLOSE_SOCKET ;// Close communication (optional)