ABB example user frame program

This example program requires that Pickit is installed and set up with your robot. For installation instructions, please refer to the ABB installation and setup article. More information about the logic of this program can be found in the robot-independent surface treatment and dispensing article.

User frames in ABB

This example uses the concept of a user frame. In ABB, work objects are used to define both the position of a fixture (user frame) and the position of the object to work on (object frame). When the fixture or the object are moved, the program may still work if the corresponding work object is updated. These coordinate systems are very well suited to off-line programming since the waypoints specified can usually be taken directly from a drawing of the work object.

If work objects are defined in move instructions, the target waypoints will be based on the coordinates of the work object. This means that programs can be reused quickly following changes in the pose of the part. When the part is shifted, only the user frame has to be updated.

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

Loading Example programs

One of the Pickit example programs can be loaded from HOME > ABB_Pick-it > Pick-it > Application examples.

Note

These example programs 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.

User frame example program

The example program Pickit_example_robot_guidance is shown below.

MODULE Pickit_example_robot_guidance

    ! Detection settings
    PERS num setup:=555;
    PERS num product:=555;
    PERS num retries:=3;
    CONST bool isCameraRobotMounted:=TRUE;

    ! Picking motion settings
    PERS tooldata PICKIT_TOOL:=[TRUE,[[0,0,0],[1,0,0,0]],[0.001,[0,0,0.001],[1,0,0,0],0,0,0]];
    CONST speeddata approachSpeed:=v100;

    ! Fixed poses
    PERS  robtarget HomePose:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9e9,9e9,9e9,9e9,9e9,9e9]];
    PERS  robtarget Detect:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9e9,9e9,9e9,9e9,9e9,9e9]];

    ! User frame set by Pickit detection results
    PERS robtarget PickitUserFrame:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9e9,9e9,9e9,9e9,9e9,9e9]];

    ! Work object that will be modified based on detection
    PERS wobjdata PICKIT_wobj:= [FALSE,TRUE,"",[[0,0,0],[0,0,0,0]],[[0,0,0],[1,0,0,0]]];

    ! Taught waypoints based on PICKIT_wobj
    ! They can be taugh after running application_setup() either manually or in offline mode
    PERS robtarget P1:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9e9,9e9,9e9,9e9,9e9,9e9]];
    PERS robtarget P2:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9e9,9e9,9e9,9e9,9e9,9e9]];
    PERS robtarget P3:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9e9,9e9,9e9,9e9,9e9,9e9]];

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ! User functions:
    !
    ! Adapt these functions based on your application
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    PROC before_start()
        ! Move to home position
        MoveL HomePose, v100, z50, PICKIT_TOOL\WObj:=wobj0;
    ENDPROC

    PROC after_end()
        MoveL HomePose, v100, z50, PICKIT_TOOL\WObj:=wobj0;
        Pickit_save_snapshot;
        Break;
    ENDPROC

    PROC goto_detection()
        ! Move to detection pose defined w.r.t to robot base
        MoveJ Detect, v100, z50, PICKIT_TOOL\WObj:=wobj0;
        IF isCameraRobotMounted THEN
            ! Wait for no vibrations in the camera.
            ! Adapt the duration depending on your application.
            WaitTime\InPos,2;
        ENDIF
    ENDPROC

    FUNC bool is_reachable()

        VAR bool isReachable;

        ! The input robtarget data should be specified in the same coordinate system
        ! as specified in argument for Tool, WObj
        isReachable:=pickit_is_pose_reachable(P1,PICKIT_TOOL,\wobj:=PICKIT_wobj)
                AND pickit_is_pose_reachable(P2,PICKIT_TOOL,\wobj:=PICKIT_wobj)
                AND pickit_is_pose_reachable(P3,PICKIT_TOOL,\wobj:=PICKIT_wobj);

        RETURN isReachable;

    ENDFUNC

    PROC follow_path()

        ! Enable tool

        ! Follow points that are already taught w.r.t to PICKIT_wobj
        MoveL P1,  approachSpeed, z0, PICKIT_TOOL\WObj:=PICKIT_wobj;
        MoveL P2,  approachSpeed, z0, PICKIT_TOOL\WObj:=PICKIT_wobj;
        MoveL P3,  approachSpeed, z0, PICKIT_TOOL\WObj:=PICKIT_wobj;

        ! Disable tool

    ENDPROC


    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ! Application setup function
    !
    ! Run this function to define the work object and then teach the waypoints
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    PROC application_setup()

        ! IF first time running this application, you need to teach the waypoints first
        ! To teach the waypoints, you need to define PICKIT_wobj based on a Pickit detection

        check_robot_mode;
        pickit_configure setup,product; ! Load desired setup and product configuration.

        ! Detection.
        goto_detection;
        pickit_detection_with_retries(retries);
        WaitUntil pickit_get_results();

        IF pickit_object_found() THEN

            ! Teach PICKIT_wobj based on detection
            PickitUserFrame:=pickit_get_pose();
            PICKIT_wobj := [FALSE,TRUE,"",
                           [PickitUserFrame.trans,PickitUserFrame.rot],
                           [[0,0,0],[1,0,0,0]]];

            ! Now you can teach points P1,...  manually or in offline mode w.r.t PICKIT_wobj

        ELSEIF Pickit_roi_empty() THEN

            ErrWrite\I,"The ROI is empty.",
            "Teaching the user frame cannot be done.";

        ELSEIF Pickit_no_image_captured() THEN

            ErrWrite\I, "Failed to capture a camera image.",
            "Teaching the user frame cannot be done.";

        ELSE

            ErrWrite\I,"Object is not detected.",
            "Teaching the user frame cannot be done.";

        ENDIF

        after_end;

    ENDPROC


    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ! Main program
    !
    ! To be called for every part
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    PROC main()

        application_setup; ! Only run this function during setup. Then it can be omitted.

        check_robot_mode;
        before_start;
        pickit_configure setup,product; ! Load desired setup and product configuration.

        ! Detection.
        goto_detection;
        pickit_detection_with_retries(retries);
        WaitUntil pickit_get_results();

        IF pickit_object_found() THEN

            !Update PICKIT_wobj based on detection
            PickitUserFrame:=pickit_get_pose();
            PICKIT_wobj := [FALSE,TRUE,"",
                           [PickitUserFrame.trans,PickitUserFrame.rot],
                           [[0,0,0],[1,0,0,0]]];

            ! Check if points are reachable
            IF is_reachable() THEN

                follow_path;

            ELSE

                ErrWrite\I,"Object is unreachable.",
                "Application cannot be completed.";

            ENDIF

        ELSEIF Pickit_roi_empty() THEN

            ErrWrite\I,"The ROI is empty.",
            "Application cannot be completed.";

        ELSEIF Pickit_no_image_captured() THEN

            ErrWrite\I, "Failed to capture a camera image.",
            "Application cannot be completed.";

        ELSE

            ErrWrite\I,"Object is not detected.",
            "Application cannot be completed.";

        ENDIF

        after_end;

    ! Collision recovery
    ERROR
        IF ERRNO=ERR_COLL_STOP THEN
            ErrWrite\W,"Collision detected, trying to recover.","";
            ! Disable tool
            StopMove;
            ClearPath;
            MotionSup\Off;
            MoveL HomePose, v100, z50, PICKIT_TOOL\WObj:=wobj0;
            MotionSup\On;
            RAISE ;
        ENDIF

    ENDPROC

    PROC check_robot_mode()
        IF NOT pickit_is_running() THEN
            ErrLog 4800,"Pickit NOT in Robot Mode",
                "Pickit is not in Robot Mode.",
                "In the Pickit web interface, click on 'Enable Robot Mode',",
                "and restart the program to start picking."," ";
            Stop;
        ENDIF
    ENDPROC

ENDMODULE

Required program inputs

  1. Define the tool for picking

    Create a tool with the actual TCP values. In this example, PICKIT_TOOL is used.

  2. Set correct constant values

    At the top of the program, the following constants need to be filled in with the correct values:

    • setup: the desired Pickit setup id.

    • product: the desired Picket product id.

  3. Define fixed poses

    • Detect: Where to perform object detection from.

    • HomePose: The start pose of the application.

  4. Application Setup

    The application_setup() procedure needs to be called only once when setting up the application. First, a Pickit detection is called. If the detection is successful, the user frame PickitUserFrame can be set to the recieved pick point pickit_get_pose(). Then, PICKIT_wobj can be updated based on PickitUserFrame. Finally, based on PICKIT_wobj, the desired trajectory waypoints P1, P2, P3 can be defined in two ways:

    • In offline mode, using RobotStudio, based on the CAD model of the part.

    • In manual mode, by jogging the robot TCP to every point and then saving the robot position with respect to PICKIT_wobj using the robot pendant.

    ../../../_images/abb-work-object.png
More trajectory points can be added based on the application.
  1. Add tool enable/disable logic

    In some applications, the tool used needs to be enabled and disabled before and after following the trajectory.

Note

In applications with robot-mounted cameras, it is a good practice to perform calibration validation before running the program (learn more). An incorrect or outdated calibration can lead to inaccurate picking.

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.