KUKA simple pick and place

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.

Attention

The examples contained in the Pickit application files contain hard-coded robot poses that should be adapted to every new robot. For PickitSimplePicking, you must reteach the XDetect, XDrop and XAbovePickArea points, choose the correct #TOOL and #BASE, and fill in the correct setup and product IDs in Pickit_configure(). When executing such programs for the first time, please do so in manual mode and at low speed to check for potential collisions.

The PickitSimplePicking program

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

DEF PickitSimplePicking( )

    ;FOLD INI;%{PE}

    PTP XHOME

    IF NOT Pickit_is_running() THEN
        IF Pickit_comm_is_ok() THEN
            PickitMessages(#info, 1) ;Pickit not in ROBOT mode
        ENDIF
        HALT
    ENDIF

    ;Fill in correct setup and product id
    Pickit_configure(1,1)
    ;Set the tool used for picking, make sure the TCP is defined correctly
    BAS(#TOOL,1)
    BAS(#BASE,0)

    PTP XDetect
    WAIT SEC 0.0 ;Wait until the robot reaches the position
    Pickit_detect_with_retr(5)
    WAIT FOR Pickit_get_results()

    LOOP ; ---- Main Loop

        IF Pickit_object_found() THEN
            ;Calculate pick points
            F_Pick=Pickit_get_pose()
            F_PrePick=F_Pick:{X 0.0,Y 0.0,Z -100.0,A 0.0,B 0.0,C 0.0}
            F_PostPick={X 0.0,Y 0.0,Z 100.0,A 0.0,B 0.0,C 0.0}:F_Pick

            ;Check if positions are reachable
            ;Note: The INVERSE function cannot guarantee that a LIN motion will be feasible
            PickitAxistest=INVERSE(F_Pick,xAbovePickArea,Pickit_ErrStatCheckPos1)
            PickitAxistest=INVERSE(F_PrePick,xAbovePickArea,Pickit_ErrStatCheckPos2)
            PickitAxistest=INVERSE(F_PostPick,xAbovePickArea,Pickit_ErrStatCheckPos3)

            IF (Pickit_ErrStatCheckPos1==0) AND (Pickit_ErrStatCheckPos2==0) AND (Pickit_ErrStatCheckPos3==0) THEN ; Position reachable

                PTP XAbovePickArea

                ;Picking sequence
                ;Conservative LIN motion parameters inside the bin
                BAS(#VEL_CP,0.5)
                BAS(#ACC_CP,1.0)

                LIN F_PrePick
                LIN F_Pick

                ;----- Add grasping logic

                WAIT SEC 1.0 ;Wait until grasping is completed

                LIN F_PostPick

                ;LIN needs a Cartesian pose, XAbovePickArea is E6AXIS, convert with FORWARD()
                XAbovePickAreaCart = FORWARD(XAbovePickArea, Pickit_ErrStatForward)
                LIN XAbovePickAreaCart

                PTP XDetect
                WAIT SEC 0.0

                Pickit_capture_image()
                Pickit_process_image()

                ;Drop the picked part at the needed location
                PTP XDrop

                ;------- Add release logic

                WAIT FOR Pickit_get_results()

                IF NOT Pickit_object_found() THEN
                    ;Retry detecting if no object found during the first detection.
                    PTP XDetect
                    WAIT SEC 0.0
                    Pickit_detect_with_retr(4)
                    WAIT FOR Pickit_get_results()
                ENDIF

            ELSE ;Position unreachable, try picking the next object
                PickitMessages(#info,2) ;Object not reachable, requesting next object
                Pickit_next_object()
                WAIT FOR Pickit_get_results()

            ENDIF

        ELSE ;No object found, or the exchange failed: exit
            IF NOT Pickit_comm_is_ok() THEN
                ;Communication failed. Program is HALTED and a message is
                ;automatically shown naming the root cause (message cases 23-32)
                EXIT
            ENDIF
            IF Pickit_roi_empty() THEN
                PickitMessages(#info, 3) ;ROI is empty
                EXIT
            ELSE
                PickitMessages(#info, 4) ;No objects found
                Pickit_save_scene()
                EXIT
            ENDIF
        ENDIF

    ENDLOOP
END

The idea of the program is the following:

  • First, it is checked whether or not Pickit is in Robot mode.

  • If so, the robot moves to the XDetect pose and a detection is triggered, otherwise the robot program is halted.

  • If an object is found, it is checked if the pick, pre-pick and post-pick points are reachable for the robot.

  • If the object is reachable, the robot moves to the object to pick it. Afterwards, the robot moves to a fixed drop-off position, XDrop. As soon as the robot is out of the field of view of the camera, a new Pickit detection is triggered, so that the detection is processed at the same time as the robot moves, optimizing cycle time.

  • If the object is not reachable, the robot requests the next detected object.

  • If the ROI is empty, the program stops.

  • If no object is found, and the ROI is not empty, a snapshot is saved on the Pickit system and the robot program stops.

Note

The listing above is a simplified rendition of the shipped program: the KUKA inline form folds around the motion instructions are collapsed into a single PTP line each. Always start from the program shipped with your Pickit installation files and adapt it to your application.

Define the tool for picking

Create a tool with the actual TCP values. In this program, #TOOL1 is used.

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 fixed points

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

  • XHome: Where the robot will start the program.

  • XDetect: Where to perform object detection from.

  • XAbovePickArea: A point roughly above the pick area from which the above two can be reached without collision.

  • XDrop: Where to place objects.

Pick sequence settings

F_PrePick and F_PostPick are derived from the pick point with a fixed 100 mm z-offset, applied in the tool frame for the pre-pick and in the robot base frame for the post-pick. Adapt both offsets to your application if necessary.

The linear motions in and out of the pick area, from F_PrePick up to the retreat to AbovePickArea, are executed with conservative Cartesian velocity and acceleration, set with BAS(#VEL_CP,0.5) and BAS(#ACC_CP,1.0). Note that #VEL_CP is expressed in m/s and #ACC_CP in m/s². Change these values if necessary.

Add grasping/releasing logic

At the F_Pick and Drop points, grasping and releasing logic needs to be added, respectively. The WAIT SEC 1.0 after the grasping logic gives the gripper time to close before the robot retracts; adapt it to your gripper.

Execute the picking 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. Happy picking!