ABB Example Program
This topic introduces the example programs that perform an actual pick-and-place task.
Prerequisites
-
You have set up the Standard Interface communication with the robot.
-
You have completed the hand-eye calibration with the calibration program.
-
Mech-Vision and Mech-Viz projects are created and set to autoload.
-
The TCP (Tool Center Point) has been correctly specified.
-
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-Mind Software Suite.
Obtain Vision Result from Mech-Vision
PROC Vision_Sample_1()
!**********************************************************
! FUNCTION:Eye to Hand simple pick and place with vis
! 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,60;
WaitTime 0.1;
!Set vision recipe
MM_Switch_Model 1,1;
!Run vision project
MM_Start_Vis 1,1,2,snap_jps;
WaitTime 1;
MM_Get_VisData 1,LastData,PoseNum,Status;
IF Status<>1100 THEN
Stop;
ENDIF
MM_Get_Pose 1,pickpoint,label,speed1;
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
-
Move the robot to HOME position.
-
Move the robot to the image-capturing pose.
-
Initialize communication with MM_Init_Socket.
-
If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_Switch_Model.
-
Run the Mech-Vision project with MM_Start_Vis.
-
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.
-
Obtain the vision result from Mech-Vision.
-
Check if the returned status code indicates any error. If an error code is returned, the program is stopped.
-
Move the robot to the picking waypoint and perform picking.
-
Move the robot to an intermediate point between the picking waypoint and placing waypoint.
-
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 vision_sample_2()
!**********************************************************
! FUNCTION:Eye to Hand simple pick and place with 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,60;
WaitTime 0.1;
!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, LastData, 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},label1{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
!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
In this example program, Mech-Viz leads the robot to pick and place objects under the guidance of vision result.
-
Move the robot to HOME position.
-
Move the robot to the image-capturing pose.
-
Initialize communication with MM_Init_Socket.
-
If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_Switch_Model.
-
Run the Mech-Viz project with MM_Start_Viz.
-
Obtain the planned path from Mech-Viz.
-
Check if the returned status code indicates any error. If an error code is returned, the program is stopped.
-
Store obtained waypoint poses in the planned path to P{} with a FOR loop.
-
Move the robot along the planned path with a FOR loop and perform picking.
-
Move the robot to an intermediate point between the placing waypoint and placing waypoint.
-
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.
-
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 Vision_Sample_3()
!**********************************************************
! FUNCTION:Eye to Hand simple pick and place with vis 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,60;
WaitTime 0.1;
!Set vision recipe
MM_Switch_Model 1,1;
!Run vision project
MM_Start_Vis 1,1,2,snap_jps;
WaitTime 1;
!get planned path from {product-vis} Path Planning Step
MM_Get_VisPath 1,2,LastData,PoseNum,VisPosNum,Status;
IF Status<>1103 THEN
Stop;
ENDIF
FOR i FROM 1 TO PoseNum DO
count:=i;
MM_Get_Pose count,P{count},label1{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
!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
-
Move the robot to HOME position.
-
Move the robot to the image-capturing pose.
-
Initialize communication with MM_Init_Socket.
-
If parameter recipes are used in the Mech-Vision project, the recipe to be used is set with MM_Switch_Model.
-
Run the Mech-Vision project with MM_Start_Vis.
-
Obtain the planned path from the “Path Planning” Step in Mech-Vision with MM_Get_VisPath.
-
Check if the returned status code indicates any error. If an error code is returned, the program is stopped.
-
Store obtained waypoint poses in the planned path to P{} with a FOR loop.
-
Move the robot along the planned path with a FOR loop and perform picking.
-
Move the robot to an intermediate point between the picking waypoint and placing waypoint.
-
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.
-
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.
-