KUKA example user frame program

This article describes the KUKA user frame program commonly used in surface treatment and dispensing applications. More information about the logic of this program can be found in the robot-independent surface treatment and dispensing article.

Note

This program requires that Pickit is installed and set up with your robot. For installation instructions, please refer to the KUKA installation and setup article.

User frames in KUKA

In KUKA, a user frame can be defined using the BASE coordinate system.

The BASE coordinate system is a Cartesian system that represents the position of a known workpiece. It is always defined relative to the WORLD coordinate system, and by default BASE[0] is identical to the WORLD coordinate system.

In the KUKA controller, the user can define up to 32 different BASE coordinate systems, from BASE[1] to BASE[32]. Changing the user frame allows to translate the entire robot trajectory without the need to apply the translation to each point separately. This is particularly useful in surface treatment and dispensing applications, where the robot’s trajectory is based on the location of a user frame.

In this example program, the user frame is defined based on a pick point sent from Pickit (updated based on a detection).

Teaching

The program PickitGuidanceTeaching.src is shown below. This program follows the generic trajectory teaching logic.

  • Before running this program, touch-up the desired trajectory points TeachP1, TeachP2, TeachP3 on the workpiece. Make sure the workpiece does not move until you run this program once.

  • Start the program.

  • Check if Pickit is in Robot mode.

  • If so, the robot moves to the detect pose and a detection is triggered.

  • If an object is found, BASE_DATA[32] is updated based on the object pose. Then the robot will move to the poses previously taught TeachP1, TeachP2, TeachP3 and will save them w.r.t the user frame BASE_DATA[32]. The saved poses are called F_Point1, F_Point2, F_point3.

  • End of the program.

This program can be found in R1 > Program > Pickit.

Note

This program only works with Pickit software version of 2.2 or greater. If you are using a software version prior 2.2, please contact us at support@pickit3d.com, and we will assist you in finding a solution.

Attention

The examples contained in the Pickit application files contain hard-coded robot poses that should be adapted to every new robot. When executing such programs for the first time, please do so in manual mode and at low speed to check for potential collisions.

DEF PickitGuidanceTeaching( )

;FOLD INI;%{PE}
;FOLD BASISTECH INI
    GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
    INTERRUPT ON 3
    BAS (#INITMOV,0 )
;ENDFOLD (BASISTECH INI)
;FOLD USER INI
    ;Make your modifications here
;ENDFOLD (USER INI)
;ENDFOLD (INI)

;Copyright (c) 2023, Pick-it NV
;All rights reserved
;V1.2 (16/03/2023)

;***********************************************************************
; Before running this program, touch-up the desired trajectory
; points TeachP1, TeachP2, TeachP3 on the workpiece.
; Make sure the workpiece does not move until you run this program once.
;***********************************************************************

;Set the tool, make sure the TCP is defined correctly
BAS(#TOOL,1)
BAS(#BASE,0)

PTP XHOME

IF NOT Pickit_is_running() THEN
PickitMessages(#info, 1)
HALT
ENDIF

;Fill in correct setup and product id
Pickit_configure(18,14)

;Go to the detect position

PTP XDetect

;Wait until the robot reaches the position
WAIT SEC 0.0

;Trigger the detection (with 5 retries)
Pickit_detect_with_retr(5)
WAIT FOR Pickit_get_results()

IF Pickit_object_found() THEN
F_ObjectDetected=Pickit_get_pose()

;Save the detection result as the Base n32, we will use it to teach the trajectory.
BASE_DATA[32]=F_ObjectDetected
$BASE=BASE_DATA[32]
BAS(#BASE,32)

;*********************************************************************************
; Move to every point of the trajectory
; Then save the points as frames: F_Point1, F_Point2, F_point3
; To add more trajectory points, define more frames in the corresponding .DAT file
;*********************************************************************************

PTP XTeachP1

WAIT SEC 0.0

$BASE=BASE_DATA[32]
F_Point1.X      = $POS_ACT.X
F_Point1.Y      = $POS_ACT.Y
F_Point1.Z      = $POS_ACT.Z
F_Point1.A      = $POS_ACT.A
F_Point1.B      = $POS_ACT.B
F_Point1.C      = $POS_ACT.C


PTP XTeachP2

WAIT SEC 0.0

$BASE=BASE_DATA[32]
F_Point2.X      = $POS_ACT.X
F_Point2.Y      = $POS_ACT.Y
F_Point2.Z      = $POS_ACT.Z
F_Point2.A      = $POS_ACT.A
F_Point2.B      = $POS_ACT.B
F_Point2.C      = $POS_ACT.C

PTP XTeachP3

WAIT SEC 0.0

$BASE=BASE_DATA[32]
F_Point3.X      = $POS_ACT.X
F_Point3.Y      = $POS_ACT.Y
F_Point3.Z      = $POS_ACT.Z
F_Point3.A      = $POS_ACT.A
F_Point3.B      = $POS_ACT.B
F_Point3.C      = $POS_ACT.C

MsgNotify("Teaching of trajectory points successful")
HALT


ELSE ;No Object found, exit
    IF Pickit_roi_empty() THEN
        PickitMessages(#info, 3)
        HALT
    ELSE
        PickitMessages(#info, 4)
        HALT
    ENDIF

ENDIF


END

See KUKA Pickit interface for more information about the Pickit macros available.

Execution

The program PickitGuidanceExecution.src is shown below. This program follows the generic trajectory execution 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, BASE_DATA[30] is updated based on the new object pose.

  • The robot follows the trajectory and goes back to the second step.

  • If the ROI is empty or no object is found, the program stops.

This program can be found in R1 > Program > Pickit.

DEF PickitGuidanceExecution( )

;FOLD INI;%{PE}
;FOLD BASISTECH INI
    GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )
    INTERRUPT ON 3
    BAS (#INITMOV,0 )
;ENDFOLD (BASISTECH INI)

;FOLD USER INI
    ;Make your modifications here
;ENDFOLD (USER INI)

;ENDFOLD (INI)

;Copyright (c) 2023, Pick-it NV
;All rights reserved
;V1.2 (16/03/2023)

PTP XHOME

IF NOT Pickit_is_running() THEN
PickitMessages(#info, 1)
HALT
ENDIF

;Fill in correct setup and product id
Pickit_configure(18,14)

;Set the tool, make sure the TCP is defined correctly
BAS(#TOOL,1)
BAS(#BASE,0)

;Go to the detect position

PTP XDetect

;Wait until the robot reaches the position
WAIT SEC 0.0

;Trigger the first detection
Pickit_detect_with_retr(5)
WAIT FOR Pickit_get_results()

LOOP
IF Pickit_object_found() THEN

    ;Change the base frame based on the new position of the workpiece
    F_ObjectDetected=Pickit_get_pose()
    BASE_DATA[30]=F_ObjectDetected
    BAS(#BASE,30)

    ;Conservative LIN motion parameters for following the trajectory
    BAS(#VEL_CP,30)
    BAS(#ACC_CP,20)

    ;Follow the trajectory taught in the PickitGuidanceTeaching routine
    ;They are declared as global in the PickitGuidanceTeaching.dat file
    LIN F_Point1
    LIN F_Point2
    LIN F_Point3

    ;Set again to the world base frame
    BAS(#BASE,0)

ENDIF

PTP XDetect
WAIT SEC 0.0

Pickit_detect_with_retr(5)
WAIT FOR Pickit_get_results()

IF NOT Pickit_object_found() THEN
    IF Pickit_roi_empty() THEN
        PickitMessages(#info, 3)
        EXIT
    ELSE
        PickitMessages(#info, 4)
        EXIT
    ENDIF
ENDIF

ENDLOOP
END

Note

These two programs use three trajectory poses as an example, but more poses can be added if needed. If a trajectory pose is added, make sure that the teaching and execution programs are modified accordingly.

See KUKA Pickit interface for more information about the Pickit macros available.

Set correct input arguments

The commands Pickit_configure and Pickit_detect_with_retr need input arguments. See Pickit communication functions for more information about these arguments.

Define the user frame

Make sure that User Frames BASE_DATA[30] and BASE_DATA[32] can be used before running the example program. Note that teaching the user frames is not necessary since they will take the value of the object pose when running the programs.

Define fixed points

In this program, 2 fixed points are used. These points need to be defined depending on the application.

  • Home: Where the robot will start the program.

  • Detect: Where to perform object detection from.

There are also 3 poses to be defined relative to the workpiece: TeachP1, TeachP2 and TeachP3. These 3 poses then are used as F_Point1, F_Point2 and F_Point3 in the execution program.

Collision recovery

In KUKA, collision detection is used to monitor the axis torques. If one of these exceed a limit value, the robot stops and operator intervention is needed.

The general preconditions for collision detection are:

  • $IMPROVED_COLLMON == TRUE.

  • $ADAP_ACC #NONE.

  • The load data are correct.

Collision detection is necessary in bin picking applications to protect the robot and the tool. However, to avoid production downtime, it is recommended to use a collision recovery strategy in the robot program. This way, if the robot collides with an object while trying to follow a trajectory, the robot does not raise an error requiring operator intervention. Instead, the robot goes back to the detection point and tries to process the next workpiece.

To implement the collision recovery in this program, first a set of torque sensitivities need to be defined in the respective .DAT file using the variables iSearchSensitivity[1], iSearchSensitivity[2], ... ,iSearchSensitivity[6]. These sensitivities should be lower than the torque limits defined in the enabled collision detection settings. When one of these limits is crossed, a flag CYCFLAG[255] is raised, which stops the robot motion and calls the RetreatWhenFound() subroutine. This will prevent the axis torques from reaching higher values that trigger a robot stop. When the RetreatWhenFound() subroutine is executed, the application can be resumed by taking another detection and trying to pick again.

Execute the user frame program

Attention

Before running the robot program for the first time, make sure that:

  • There exists a valid robot-camera calibration.

  • The Tool Center Point (TCP) has been correctly specified.

  • The robot speed is set to a low value, so unexpected behavior can be identified early enough to prevent the robot from colliding with people or the environment.

  • Pickit is in robot mode, which is enabled in the Pickit web interface.

Now you can run the program.