ABB Example Program

This topic introduces the example programs that perform an actual pick-and-place task.

Prerequisites

  1. You have set up the Standard Interface communication with the robot.

  2. You have completed the hand-eye calibration with the calibration program.

  3. Mech-Vision and Mech-Viz projects are created and set to autoload.

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

  5. The robot velocity is reduced to avoid collision and other safety hazards during testing.

Example Programs

The example programs are stored in Mech-Center/Robot_Interface/ABB/sample in the installation directory of Mech-Vision & Mech-Viz.

Obtain Vision Result from Mech-Vision

PROC Sample_1()
    !**********************************************************
    ! FUNCTION:Eye to Hand simple pick and place with Mech-Vision
    ! 2022-5-1
    !**********************************************************
    AccSet 100, 100;
    VelSet 100, 5000;
    MoveAbsJ Home\NoEOffs,v3000,fine,Gripp1TCP;!move robot home position
    MoveL camera_capture,v500,fine,Gripp1TCP;
    PoseNum:=0;
    !Set ip address of IPC
    MM_Init_Socket "127.0.0.1",50000,300;
    WaitTime 0.1;
    MM_Open_Socket;
    !Set vision recipe
    MM_Switch_Model 1,1;
    !Run vision project
    MM_Start_Vis 1,0,2,snap_jps;
    WaitTime 1;
    MM_Get_VisData 1,PoseNum,Status;
    IF Status<>1100 THEN
        Stop;
    ENDIF
    MM_Get_Pose 1,pickpoint,label,speed;
    MM_Close_Socket;
    MoveL RelTool(pickpoint,0,0,-100),v1000,fine,Gripp1TCP;
    MoveL pickpoint,v300,fine,Gripp1TCP;
    Stop;
    !Add object grasping logic here.
    MoveL Offs(pickpoint,0,0,100), v1000, fine, Gripp1TCP;
    MoveL waypoint1,v1000,z50,Gripp1TCP;
    MoveL RelTool(drop,0,0,-100),v1000,fine,Gripp1TCP;
    MoveL drop,v300,fine,Gripp1TCP;
    Stop;
    !Add object releasing logic here.
    MoveL Offs(drop,0,0,100), v1000, fine, Gripp1TCP;
    MoveAbsJ Home\NoEOffs,v3000,fine,Gripp1TCP;
    RETURN ;
ENDPROC

Program Logic

  1. Move the robot to the Home position.

  2. Move the robot to the image-capturing pose.

  3. Initialize communication with MM_Init_Socket.

  4. Start TCP/IP connection with MM_Open_Socket.

  5. If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_Switch_Model.

  6. Run the Mech-Vision project with MM_Start_Vis.

  7. Wait for 1 second. Under Eye-In-Hand, this WaitTime instruction is required to make sure the robot stays still until image acquisition is completed. Under Eye-To-Hand, this WaitTime instruction can be replaced with MoveL or MoveJ.

  8. Obtain the vision result from Mech-Vision.

  9. Check if the returned status code indicates any error. If an error code is returned, the program is stopped.

  10. Store the retrieved TCPs in the specified variable.

  11. End TCP/IP connection by calling MM_Close_Socket.

  12. Move the robot to the picking waypoint and perform picking.

  13. Move the robot to an intermediate point between the picking waypoint and placing waypoint.

  14. Move the robot to the set placing waypoint and perform placing.

Customization Required

  • Define the TCP (Tool Center Point)

    The TOOL is defined as Gripp1TCP. Change the value of Gripp1TCP to the actual TCP values.

  • Define Home Position

    Set the Home position in Home.

  • Teach the Image-Capturing Pose

    Record the image-capturing pose in camera_capture.

  • Teach the Intermediate Point(s)

    Intermediate points are between the picking pose and placing pose and are used to ensure that the robot doesn’t collide with the surrounding when moving between the picking and placing poses. You can add one or more intermediate points to waypoint of MoveL waypoint1.

  • Teach the Placing Pose

    Record the placing pose in drop.

  • Z-offset distances relative to the tool frame from the picking/placing pose are used to ensure collision doesn’t occur when the robot is approaching or departing the picking/placing pose.

    • Approach waypoint of picking

      MoveL RelTool(pickpoint,0,0,-100): the Z-offset when approaching the picking pose is set to 100 mm. The robot will move to 100 mm above the picking pose.

    • Departure waypoint of picking

      MoveL Offs(pickpoint,0,0,100): the Z-offset when departing the picking pose is set to 100 mm. The robot will move to 100 mm above the picking pose.

    • Approach waypoint of placing

      MoveL RelTool(drop,0,0,-100): the Z-offset when approaching the placing pose is set to 100 mm. The robot will move to 100 mm above the placing pose.

    • Departure waypoint of placing

      MoveL Offs(drop,0,0,100): the Z-offset when departing the placing pose is set to 100 mm. The robot will move to 100 mm above the placing pose.

  • Add the Object Picking and Releasing Logics for the Tool

    When the robot moves to the picking waypoint and the placing waypoint, you need to add the tool control logics for picking and releasing the object respectively.

Obtain Planned Path from Mech-Viz

PROC Sample_2()
    !**********************************************************
    ! FUNCTION:Eye to Hand simple pick and place with Mech-Viz
    ! 2022-5-1
    !**********************************************************
    AccSet 100, 100;
    VelSet 100, 5000;
    MoveAbsJ Home\NoEOffs,v3000,fine,Gripp1TCP;!move robot home position
    MoveL camera_capture,v500,fine,Gripp1TCP;
    PoseNum:=0;
    !Set ip address of IPC
    MM_Init_Socket "127.0.0.1",50000,300;
    WaitTime 0.1;
    MM_Open_Socket;
    !Set vision recipe
    MM_Switch_Model 1,1;
    !Run Viz project
    MM_Start_Viz 1,snap_jps;
    WaitTime 0.1;
    !set branch exitport
    MM_Set_Branch 1,1;
    !get planned path
    MM_Get_VizData 2, PoseNum, VisPosNum, MM_Status;
    IF MM_Status <> 2100 THEN
        Stop;
    ENDIF
    FOR i FROM 1 TO PoseNum DO
        count:=i;
        MM_Get_Pose count,P{count},label{count},speed{count};
    ENDFOR
    !follow the planned path to pick
    FOR j FROM 1 TO PoseNum DO
        count:=j;
        MoveL p{count},v1000,fine,Gripp1TCP;
        IF count=VisPosNum THEN
            Stop;
            !add object grasping logic here
        ENDIF
    ENDFOR
    MM_Close_Socket;
    !go to drop location
    MoveL RelTool(drop,0,0,-100),v1000,z50,Gripp1TCP;
    MoveL drop,v500,fine,Gripp1TCP;!drop point
    stop;
    !add object releasing logic here
    MoveL Offs(drop,0,0,100), v1000, fine, Gripp1TCP;
    MoveAbsJ Home\NoEOffs,v3000,fine,Gripp1TCP;
    RETURN ;
ENDPROC

Program Logic

This example program uses Mech-Viz for vision-guided picking and placing objects to the set placing waypoint.

  1. Move the robot to the Home position.

  2. Move the robot to the image-capturing pose.

  3. Initialize communication with MM_Init_Socket.

  4. Start TCP/IP connection with MM_Open_Socket.

  5. If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_Switch_Model.

  6. Run the Mech-Viz project.

  7. Obtain the planned path from Mech-Viz.

  8. Check if the returned status code indicates any error. If an error code is returned, the program is stopped.

  9. Store obtained waypoint poses in the planned path to the variable with a FOR loop.

  10. Move the robot along the path planned by Mech-Viz with a FOR loop and perform picking.

  11. End TCP/IP connection by calling MM_Close_Socket.

  12. Move the robot to an intermediate point between the placing waypoint and placing waypoint.

  13. Move the robot to the set placing waypoint and perform placing.

Customization Required

  • Define the TCP (Tool Center Point)

    The TOOL is defined as Gripp1TCP. Change the value of Gripp1TCP to the actual TCP values.

  • Define Home Position

    Set the Home position in Home.

  • Teach the Image-Capturing Pose

    Record the image-capturing pose in camera_capture.

  • Teach the Intermediate Point(s)

    Intermediate points are between the picking pose and placing pose and are used to ensure that the robot doesn’t collide with the surrounding when moving between the picking and placing poses. You can add one or more intermediate points to waypoint of MoveL waypoint1.

  • Teach the Placing Pose

    MoveL drop: Record the placing waypoint in drop.

  • Add the Object Picking and Releasing Logics for the Tool

    When the robot moves to the picking waypoint and the placing waypoint, you need to add the tool control logics for picking and releasing the object respectively.

  • Define Z-Offset from Picking/Placing Pose

    • Approach waypoint of placing

      MoveL RelTool(drop,0,0,-100): the Z-offset when approaching the placing pose is set to 100 mm. The robot will move to 100 mm above the placing pose.

    • Departure waypoint of placing

      MoveL Offs(drop,0,0,100): the Z-offset when departing the placing pose is set to 100 mm. The robot will move to 100 mm above the placing pose.

Obtain Planned Path from Mech-Vision

PROC Sample_3()
    !**********************************************************
    ! FUNCTION:Eye to Hand simple pick and place with Mech-Vision Path Planning Step
    ! 2023-1-10
    !**********************************************************
    AccSet 100, 100;
    VelSet 100, 5000;
    MoveAbsJ Home\NoEOffs,v3000,fine,Gripp1TCP;!move robot home position
    MoveL camera_capture,v500,fine,Gripp1TCP;
    PoseNum:=0;
    !Set ip address of IPC
    MM_Init_Socket "127.0.0.1",50000,300;
    WaitTime 0.1;
    MM_Open_Socket;
    !Set vision recipe
    MM_Switch_Model 1,1;
    !Run vision project
    MM_Start_Vis 1,0,2,snap_jps;
    WaitTime 1;
    !get planned path from Mech-Vision Path Planning Step
    MM_Get_VisPath 1,2,PoseNum,VisPosNum,Status;
    IF Status<>1103 THEN
        Stop;
    ENDIF
    FOR i FROM 1 TO PoseNum DO
        count:=i;
        MM_Get_Pose count,P{count},label{count},speed{count};
    ENDFOR
    !follow the planned path to pick
    FOR j FROM 1 TO PoseNum DO
        count:=j;
        MoveL p{count},v1000,fine,Gripp1TCP;
        IF count=VisPosNum THEN
            Stop;
            !add object grasping logic here
        ENDIF
    ENDFOR
    MM_Close_Socket;
    !go to drop location
    MoveL RelTool(drop,0,0,-100),v1000,z50,Gripp1TCP;
    MoveL drop,v500,fine,Gripp1TCP;!drop point
    stop;
    !add object releasing logic here
    MoveL Offs(drop,0,0,100), v1000, fine, Gripp1TCP;
    MoveAbsJ Home\NoEOffs,v3000,fine,Gripp1TCP;
    RETURN ;
ENDPROC

Program Logic

  1. Move the robot to the Home position.

  2. Move the robot to the image-capturing pose.

  3. Initialize communication with MM_Init_Socket.

  4. Start TCP/IP connection with MM_Open_Socket.

  5. If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_Switch_Model.

  6. Run the Mech-Vision project with MM_Start_Vis.

  7. Obtain the planned path from the “Path Planning” Step in Mech-Vision with MM_Get_VisPath.

  8. Check if the returned status code indicates any error. If an error code is returned, the program is stopped.

  9. Store obtained waypoint poses in the planned path to the variable with a FOR loop.

  10. Move the robot along the planned path with a FOR loop and perform picking.

  11. End TCP/IP connection by calling MM_Close_Socket.

  12. Move the robot to an intermediate point between the picking waypoint and placing waypoint.

  13. Move the robot to the set placing waypoint and perform placing.

Customization Required

  • Define the TCP (Tool Center Point)

    The TOOL is defined as Gripp1TCP. Change the value of Gripp1TCP to the actual TCP values.

  • Define Home Position

    Set the Home position in Home.

  • Teach the Image-Capturing Pose

    Record the image-capturing pose in camera_capture.

  • Teach the Intermediate Point(s)

    Intermediate points are between the picking pose and placing pose and are used to ensure that the robot doesn’t collide with the surrounding when moving between the picking and placing poses. You can add one or more intermediate points to waypoint of MoveL waypoint1.

  • Teach the Placing Pose

    MoveL drop: Record the placing waypoint in drop.

  • Add the Object Picking and Releasing Logics for the Tool

    When the robot moves to the picking waypoint and the placing waypoint, you need to add the tool control logics for picking and releasing the object respectively.

  • Define Z-Offset from Picking/Placing Pose

    • Approach waypoint of placing

      MoveL RelTool(drop,0,0,-100): the Z-offset when approaching the placing pose is set to 100 mm. The robot will move to 100 mm above the placing pose.

    • Departure waypoint of placing

      MoveL Offs(drop,0,0,100): the Z-offset when departing the placing pose is set to 100 mm. The robot will move to 100 mm above the placing pose.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.