Warning
You are reading the documentation for an older Pickit release (3.3). Documentation for the latest release (3.4) can be found here.
Fanuc example picking program
This article describes the Fanuc example picking program. Then, it explains how to adapt the program to start running it. It is ideal to get started with Pickit.
PICKIT_SIMPLE_PICKING: program overview
The program follows the generic Pickit example program logic.
First check if Pickit is in Robot mode.
If so, the robot moves to its detect pose and a detection is triggered.
If an object is found and if it is reachable, the robot moves to the object to pick it. Next, the robot moves to a fixed drop off position. During these motions when the robot is out the field of view of the camera, a new Pickit detection is triggered immediately.
If the ROI is empty, the program stops.
If no object is found but ROI is not empty, a Snapshots is saved on the Pickit system and the robot program stops.
This program can be found in Select.
Note
The program presented here is for recent controllers (R-30iB and R-30iB plus). For older controllers, adapted programs are provided. For R-30iA controllers, a program called PICKIT_SIMPLE_PICKING_V7 is provided. The program is the same, but uses JUMP statements instead of the IF ELSE statements (not supported in this older version). For R-J3iB controllers, a program EX_PICK.TP called is provided where all macro names are adapted to shorter names.
Tip
For fixed camera setups, it is recommended to replace the consecutive calls to PI_CAPTURE_IMAGE()
and PI_PROCESS_IMAGE()
by a call to PI_LOOK_FOR_OBJECT()
.
That way the robot program will not wait for the image to be captured to continue.
1: !Program settings ;
2: !Fill in settings below ;
3: UFRAME_NUM=0 ;
4: UTOOL_NUM=1 ;
5: R[1:setup id]=3 ;
6: R[2:product id]=2 ;
7: R[3:max detect]=5 ;
8: R[4:pre offset]=(-100) ;
9: R[5:post offset]=(-100) ;
10: ;
11: ;
12: !Init ;
13: CALL PI_OPEN_COMMUNICATION ;
14: CALL PI_RUN ;
15: IF (R[151:pi status]<>0) THEN ;
16: MESSAGE[Not in robot mode] ;
17: JMP LBL[2] ;
18: ENDIF ;
19: CALL PI_CONFIGURE(R[1:setup id],R[2:product id]) ;
20: CALL PI_SET_OFFSET(R[4:pre offset],1) ;
21: CALL PI_SET_OFFSET(R[5:post offset],2) ;
22: ;
23: !First detection ;
24:J P[1:detect] 100% CNT100 ;
25: CALL PI_DETECTION_WITH_RETRIES(R[3:max detect]) ;
26: CALL PI_GET_RESULT ;
27: ;
28: ;
29: !Main Loop ;
30: LBL[1] ;
31: ;
32: !If object found ;
33: IF (R[150:pi obj status]=20) THEN ;
34: ;
35: !If reachable ;
36: CALL PI_REACH ;
37: IF (R[160:pi reach status]=0) THEN ;
38: ;
39: !Picking ;
40:J P[2:above bin] 100% CNT100 ;
41: !Move to pre pick pose ;
42:L PR[51:pi pick pose] 100mm/sec CNT100 Tool_Offset,PR[1:pre offset] ;
43: !Move to pick pose ;
44:L PR[51:pi pick pose] 100mm/sec FINE ;
45: !Add grasping logic ;
46: !Move to post pick pose ;
47:L PR[51:pi pick pose] 100mm/sec CNT100 Tool_Offset,PR[2:post offset] ;
48:L P[2:above bin] 100mm/sec CNT100 ;
49: !Detection ;
50:J P[1:detect] 100% CNT100 ;
51: CALL PI_CAPTURE_IMAGE ;
52: CALL PI_PROCESS_IMAGE ;
53: ;
54: !Drop off ;
55:J P[3:drop off] 100% FINE ;
56: !Add release logic ;
57:J P[1:detect] 100% CNT100 ;
58: ;
59: !Get detection results ;
60: CALL PI_GET_RESULT ;
61: ;
62: !Not reachable ;
63: ELSE ;
64: !Try next object ;
65: CALL PI_NEXT_OBJECT ;
66: CALL PI_GET_RESULT ;
67: ENDIF ;
68: ;
69: !No object found ;
70: ELSE ;
71: !Empty ROI ;
72: IF (R[150:pi obj status]=23) THEN ;
73: MESSAGE[ROI is empty] ;
74: JMP LBL[2] ;
75: !No object found ;
76: ELSE ;
77: MESSAGE[No object found] ;
78: CALL PI_SAVE_SCENE ;
79: JMP LBL[2] ;
80: ENDIF ;
81: ENDIF ;
82: JMP LBL[1] ;
83: LBL[2] ;
END
See Pickit macros for more information about the Pickit rountines available.
Before running the program
This example program requires Pickit to be installed and set up with your robot. For installation instructions, please refer to the Fanuc installation and setup article.
Make sure that Calibration is done. This can be done by running the Fanuc calibration program.
Run PI_SET_PICK_POSE
Before executing the picking program we first need to define the robot joint configuration for picking.
This is done by jogging the robot to the center of the picking area and manually run the PI_SET_PICK_POSE()
macro.
The macro will read out the current joint configuration of the robot and this will be used as seed for all calculated pick poses.
Define the tool for picking
Create a tool frame with the actual TCP values. In this example UTOOL1 is used.
Adapt the registers used in PICKIT_SIMPLE_PICKING
Below you find an overview of the registers used in this example program. They should be adapted according the changes you want to apply to this example program.
Note
The Pickit registers, in the 140-160 range, and the Pickit pose registers, in the 50 range, can’t be changed by the user. An overview of these can be found in the Fanuc Pickit interface article.
Variable |
Field name |
Comment |
---|---|---|
R[1] |
Setup |
Requested Pickit setup ID |
R[2] |
Product |
Requested Pickit product ID |
R[3] |
Retries |
Maximum number of detection retries |
R[4] |
Pre pick offset |
Z offset used to defined the pre pick pose offset (use a negative value). |
R[5] |
Post pick offset |
Z offset used to defined the post pick pose offset (use a negative value). |
P[1] |
Detect pose |
Position not blocking the field of view of the camera when triggering detections |
P[2] |
Above bin pose |
Position above the picking area |
P[3] |
Drop off pose |
Position where the object is dropped off |
PR[1] |
Pre pick pose |
Position offset the robot moves to before picking the object (relative to tool frame) |
PR[2] |
Post pick pose |
Position offset the robot moves to after picking the object (relative to tool frame) |
Add grasping/releasing logic
At the pi pose and drop off pose positions, grasping and releasing logic needs to be added, respectively.
Execute the picking program
Now you can run the program. Happy picking!
Collision recovery
To avoid production downtime, it is recommended to add a collision recovery in the robot program. That way, if a collision is detected by the robot while trying to pick a part, the robot does not raise an error requiring an operator intervention. Instead, the robot goes back to the detection and try to pick another part.
In Fanuc, this is done using the Skip instruction. If a condition is met, the motion is interupted. By using a condition of a joint torque being above a certain threshold, one can catch collision before the raise an alarm.
From R30iB, touch skip option [A05B-2600-J921] is required.
Note
The variable $MISC_MSTR.$HPD_ENB must be set to 1 to use the feature. The robot motion is typically slowed down for the function to detect correctly collisions.
An example using touch skip is shown below.
//$MISC_MSTR.$HPD_ENB=1 ;
CALL SETSKCOL(1,1) ;
CALL CLSKP_G1 ;
L P[2] 100mm/sec FINE Skip,LBL[1],PR[180]=LPOS ;
LBL[2: touch detected] ;
LBL[1: no touch detected] ;
It is also possible to directly set the thresholds in the tp program as shown below.
//$MISC_MSTR.$HPD_ENB=1 ;
SKIP CONDITION $MISC[1].$HPD_TRQ[2]<(-3.1) OR $MISC[1].$HPD_TRQ[2]>2.1 ;
L P[2] 100mm/sec FINE Skip,LBL[1],PR[180]=LPOS ;
LBL[2: touch detected] ;
LBL[1: no touch detected] ;
Refer to Fanuc documentation for more details.