KUKA Example Program¶
This topic introduces the example programs provided with Mech-Mind Software Suite and the operations required to perform an actual pick-and-place task.
Three example programs are provided:
The sample programs are stored in xxx\Mech-Mind Software Suite-x.x.x\Mech-Center\Robot_Interface\KUKA\sample.
Before running the program, please make sure that:
You have set up 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 has been correctly specified.
The robot velocity is set to a low value, so that the operator can notice any unexpected behavior before accidents occur.
Obtain Vision Result from Mech-Vision¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | &ACCESS RVO
&REL 5
DEF MM_SAMPLE01 ( )
;FUNCTION:Eye to Hand simple pick and place with Mech-Vision
;mechmind, 2022-5-31
INT Job
INT Pos_Num
INT Last_Data
INT MM_Status
E6POS MM_pick
E6POS MM_waypoint
E6POS MM_camera_capture
E6POS MM_drop
INT MM_Label
INT MM_Speed
;FOLD PTP HOME Vel=100 % DEFAULT;%{PE}%R 8.3.44,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,100)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
BAS(#TOOL,1)
LIN MM_camera_capture
;Set ip address of IPC
MM_Init_Socket("XML_Kuka_MMIND",873,871,60)
wait sec 0.1
;Set vision recipe
MM_Switch_Model(1,1)
;Run vision project
MM_Start_Vis(1,1,2,snap_jps)
wait sec 1
MM_Get_VisData(1,Last_Data,Pos_Num,MM_Status)
IF MM_Status<> 1100 THEN
halt
ENDIF
MM_Get_Pose(1,MM_pick,MM_Label,MM_Speed )
MM_pick.z=MM_pick.z+100
LIN MM_pick
MM_pick.z=MM_pick.z-100
LIN MM_pick
;Add object grasping logic here.
LIN_REL {z -100}#TOOL
LIN MM_waypoint
MM_drop.z=MM_drop.z+100
LIN MM_drop
MM_drop.z=MM_drop.z-100
LIN MM_drop
;Add object releasing logic here.
LIN_REL {z -100}#TOOL
;FOLD PTP HOME Vel=100 % DEFAULT;%{PE}%R 8.3.44,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,100)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
END
|
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 WAIT SEC instruction is required to make sure the robot stays still until image acquisition is completed. Under Eye-To-Hand, this WAIT SEC instruction can be replaced with motion commands.
Obtain the vision point from Mech-Vision.
Check if the returned status code indicates any error. If an error code is returned, the program is halted.
Store the obtained vision pose (picking pose) to MM_pick with MM_Get_Pose.
Move the robot to the picking pose and perform picking.
Move the robot to an intermediate point between the picking pose and placing pose.
Move the robot to the set placing pose and perform placing.
Return the robot to HOME position.
The following parts should be modified according to your actual needs.
Define the TCP¶
Change BAS(#TOOL,1) in line 25 to the tool coordinate system to which the actual TCP is saved.
Teach the image-capturing pose¶
Record the image-capturing pose in MM_camera_capture in line 26.
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 waypoints to MM_waypoint in line 46.
Teach the Placing Pose¶
Record the placing pose in MM_drop in line 48.
Define Z-Offset from Picking/Placing Pose¶
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.
Adjust the following commands according to your actual needs.
MM_pick.z=MM_pick.z+100 in line 40: the Z-offset when approaching the picking pose is set to 100. The robot will move to 100 mm above the picking pose.
LIN_REL {z -100}#TOOL in line 45: the Z-offset when departing the picking pose is set to 100. The robot will move to 100 mm above the picking pose.
MM_drop.z=MM_drop.z+100 in line 47: the Z-offset when approaching the placing pose is set to 100. The robot will move to 100 mm above the placing pose.
LIN_REL {z -100}#TOOL in line 52: the Z-offset when departing the placing pose is set to 100. The robot will move to 100 mm above the placing pose.
Add Object Grasping and Releasing Logics¶
Add logic for controlling the tool action when picking the object to line 44.
Add logic for controlling the tool action when placing the object to line 51.
Define HOME position¶
Teach the HOME position before running the program.
Obtain Planned Path from Mech-Viz¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | &ACCESS RVO
&REL 2
DEF MM_SAMPLE02 ( )
INT Job
INT Pos_Num
INT VisPos_Num
INT Last_Data
INT MM_Status
DECL E6POS MM_movepoint[20]
E6POS MM_waypoint
E6POS MM_camera_capture
E6POS MM_drop
DECL INT MM_Label[20]
INT MM_Speed[20]
INT count
;FOLD PTP HOME Vel=100 % DEFAULT;%{PE}%R 8.3.44,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,100)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
BAS(#TOOL,1)
LIN MM_camera_capture
;Set ip address of IPC
MM_Init_Socket("XML_Kuka_MMIND",873,871,60)
wait sec 0.1
;Set vision recipe
;MM_Switch_Model(1,1)
;Run Viz project
MM_Start_Viz(1,snap_jps)
wait sec 0.1
;set branch exitport
;MM_Set_Branch(1,1)
;get planned path
MM_Get_VizData(2,Last_Data,Pos_Num,VisPos_Num,MM_Status)
IF MM_Status<> 2100 THEN
halt
ENDIF
FOR count=1 TO Pos_Num
MM_Get_Pose(count,MM_movepoint[count],MM_Label[count],MM_Speed[count])
ENDFOR
;follow the planned path to pick
FOR count=1 TO Pos_Num
LIN MM_movepoint[count]
IF count==VisPos_Num THEN
;add object grasping logic here
ENDIF
ENDFOR
;go to drop location
LIN MM_waypoint
MM_drop.z=MM_drop.z+100
LIN MM_drop
MM_drop.z=MM_drop.z-100
LIN MM_drop
;Add object releasing logic here.
LIN_REL {z -100}#TOOL
;FOLD PTP HOME Vel=100 % DEFAULT;%{PE}%R 8.3.44,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,100)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
END
|
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-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 halted.
Store obtained waypoints in the planned path to MM_movepoint[] 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 pose and placing pose.
Move the robot to the set placing pose and perform placing.
Return the robot to HOME position.
The following parts should be modified according to your actual needs.
Define the TCP¶
Change BAS(#TOOL,1) in line 25 to the tool coordinate system to which the actual TCP is saved.
Teach the image-capturing pose¶
Record the image-capturing pose in MM_camera_capture in line 26.
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 waypoints to MM_waypoint in line 53.
Teach the Placing Pose¶
Record the placing pose in MM_drop in line 55.
Add Object Grasping and Releasing Logics¶
Add logic for controlling the tool action when picking the object to line 49.
Add logic for controlling the tool action when placing the object to line 58.
Define HOME position¶
Teach the HOME position before running the program.
Obtain Planned Path from Mech-Vision¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | &A&ACCESS RVO
&REL 2
DEF MM_SAMPLE03 ( )
;FUNCTION:Eye to Hand simple pick and place with Mech-Vision Path Planning Step
;mechmind, 2023-1-10
INT Pos_Num
INT VisPos_Num
INT Last_Data
INT MM_Status
DECL E6POS MM_movepoint[20]
E6POS MM_waypoint
E6POS MM_camera_capture
E6POS MM_drop
INT MM_Label[20]
INT MM_Speed[20]
INT count
;FOLD PTP HOME Vel=100 % DEFAULT;%{PE}%R 8.3.44,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,100)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
BAS(#TOOL,1)
LIN MM_camera_capture
;Set ip address of IPC
MM_Init_Socket("XML_Kuka_MMIND",873,871,60)
wait sec 0.1
;Set vision recipe
MM_Switch_Model(1,1)
;Run vision project
MM_Start_Vis(1,1,2,snap_jps)
wait sec 1
;get planned path
MM_Get_VisPath(1,2,Last_Data,Pos_Num,VisPos_Num,MM_Status)
IF MM_Status<> 1103 THEN
halt
ENDIF
FOR count=1 TO Pos_Num
MM_Get_Pose(count,MM_movepoint[count],MM_Label[count],MM_Speed[count])
ENDFOR
;follow the planned path to pick
FOR count=1 TO Pos_Num
LIN MM_movepoint[count]
IF count==VisPos_Num THEN
;add object grasping logic here
ENDIF
ENDFOR
;go to drop location
LIN MM_waypoint
MM_drop.z=MM_drop.z+100
LIN MM_drop
MM_drop.z=MM_drop.z-100
LIN MM_drop
;Add object releasing logic here.
LIN_REL {z -100}#TOOL
;FOLD PTP HOME Vel=100 % DEFAULT;%{PE}%R 8.3.44,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT
$BWDSTART=FALSE
PDAT_ACT=PDEFAULT
FDAT_ACT=FHOME
BAS(#PTP_PARAMS,100)
$H_POS=XHOME
PTP XHOME
;ENDFOLD
END
|
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 Mech-Visiion with MM_Get_VisPath.
Check if the returned status code indicates any error. If an error code is returned, the program is halted.
Store obtained waypoints in the planned path to MM_movepoint[] 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 pose and placing pose.
Move the robot to the set placing pose and perform placing.
Return the robot to HOME position.
The following parts should be modified according to your actual needs.
Define the TCP¶
Change BAS(#TOOL,1) in line 26 to the tool coordinate system to which the actual TCP is saved.
Teach the image-capturing pose¶
Record the image-capturing pose in MM_camera_capture in line 27.
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 waypoints to MM_waypoint in line 52.
Teach the Placing Pose¶
Record the placing pose in MM_drop in line 54.
Define Z-Offset from Placing Pose¶
Z-offset distances relative to the tool frame from the placing pose are used to ensure collision doesn’t occur when the robot is approaching or departing the placing pose.
Adjust the following commands according to your actual needs.
MM_drop.z=MM_drop.z+100 in line 53: the Z-offset when approaching the placing pose is set to 100. The robot will move to 100 mm above the placing pose.
LIN_REL {z -100}#TOOL in line 58: the Z-offset when departing the placing pose is set to 100. The robot will move to 100 mm above the placing pose.
Add Object Grasping and Releasing Logics¶
Add logic for controlling the tool action when picking the object to line 48.
Add logic for controlling the tool action when placing the object to line 57.
Define HOME position¶
Teach the HOME position before running the program.