Difference between revisions of "Program Examples - Robot Pick and Place (P&P)"
Line 24: | Line 24: | ||
' module global variables | ' module global variables | ||
− | dim shared | + | dim shared ZeroPosition as joint of xyzypr = {0 , 0 , 0 , 0 , 0 , 0} |
− | dim shared | + | dim shared P1Position as joint of xyzypr = {120,45,0,0,45,0} |
dim shared P1 as location of xyzypr = #{-650.776 , 1127.18 , -151.419 , 0 , 180 , -120} | dim shared P1 as location of xyzypr = #{-650.776 , 1127.18 , -151.419 , 0 , 180 , -120} | ||
Line 36: | Line 36: | ||
program | program | ||
− | with Puma | + | with Puma 'set default group element, no need to explicitly indicate the motion element |
− | Attach | + | Attach 'Attach the task to motion element (with Puma) |
En = TRUE | En = TRUE | ||
Sleep 100 | Sleep 100 | ||
− | Vcruise = RobotVelocity | + | Vcruise = RobotVelocity 'Set robot's cruise velocity |
while NOT En | while NOT En | ||
Sleep 100 | Sleep 100 | ||
end while | end while | ||
− | Move | + | Move ZeroPosition 'moving to zero position |
call waitMotion | call waitMotion | ||
− | call pickPlaceXYZ | + | call pickPlaceXYZ 'execute main function |
− | Move | + | Move ZeroPosition |
call waitMotion | call waitMotion | ||
Detach | Detach | ||
Line 59: | Line 59: | ||
dim i as long | dim i as long | ||
− | Move PUMA | + | Move PUMA P1Position |
call waitMotion | call waitMotion | ||
Puma.BlendingMethod = 1 | Puma.BlendingMethod = 1 | ||
Line 77: | Line 77: | ||
call waitMotion | call waitMotion | ||
next i | next i | ||
− | Move PUMA | + | Move PUMA ZeroPosition |
call waitMotion | call waitMotion | ||
Line 90: | Line 90: | ||
== Pick & Place - Joints == | == Pick & Place - Joints == | ||
− | + | PnPJnt.PRG: | |
− | + | <syntaxhighlight lang="vb"> | |
'------------------------------------------------------------------------------ | '------------------------------------------------------------------------------ | ||
' File: PnPJnt.prg | ' File: PnPJnt.prg |
Revision as of 14:44, 22 January 2017
Here are 2 examples of doing Robot Pick and Place. One using Cartesian coordinates, second using robot's Joints for movement. We use puma 6 axis robot in this example.
Pick & Place - Cartesian
P1 | P11 | P22 | P2 |
'------------------------------------------------------------------------------
' File: PnPTrn.prg
' Purpose: Robot Pick & Place
' Version: 1.00
' Author: Or Karni
' History: 17.JAN.2017 - created
'------------------------------------------------------------------------------
' module global "constants"
' module global variables
dim shared ZeroPosition as joint of xyzypr = {0 , 0 , 0 , 0 , 0 , 0}
dim shared P1Position as joint of xyzypr = {120,45,0,0,45,0}
dim shared P1 as location of xyzypr = #{-650.776 , 1127.18 , -151.419 , 0 , 180 , -120}
dim shared P11 as location of xyzypr = #{-650.776 , 1127.18 , -51.419 , 0 , 180 , -120}
dim shared P22 as location of xyzypr = #{650.759 , 1127.15 , -51.4505 , 0 , 180 , -60}
dim shared P2 as location of xyzypr = #{650.759 , 1127.15 , -151.4505 , 0 , 180 , -60}
dim shared RobotVelocity as double = 40.0
program
with Puma 'set default group element, no need to explicitly indicate the motion element
Attach 'Attach the task to motion element (with Puma)
En = TRUE
Sleep 100
Vcruise = RobotVelocity 'Set robot's cruise velocity
while NOT En
Sleep 100
end while
Move ZeroPosition 'moving to zero position
call waitMotion
call pickPlaceXYZ 'execute main function
Move ZeroPosition
call waitMotion
Detach
end with
end program
sub pickPlaceXYZ
dim i as long
Move PUMA P1Position
call waitMotion
Puma.BlendingMethod = 1
Puma.Cp = 50
for i = 1 to 10
Moves Puma P11
call waitMotion
Moves Puma P1
call waitMotion
Moves Puma P11
call waitMotion
Moves Puma P22
call waitMotion
Moves Puma P2
call waitMotion
Moves Puma P22
call waitMotion
next i
Move PUMA ZeroPosition
call waitMotion
end sub
sub waitMotion
while puma.IsMoving
Sleep 1
end while
end sub
Pick & Place - Joints
PnPJnt.PRG:
'------------------------------------------------------------------------------
' File: PnPJnt.prg
' Purpose: Robot Pick & Place
' Version: 1.00
' Author: Eran Korkidi
' History: 10.DEC.2015 - created
'------------------------------------------------------------------------------
dim shared jntZeroPosition as joint of xyzypr = {0,0,0,0,0,0}
dim shared jntPickHigh as joint of xyzypr = {120,45,0,0,45,0}
dim shared jntPickLow as joint of xyzypr = {120 , 49.9504 , 0.352258 , 0 , 39.6973 , 0}
dim shared jntPlaceHigh as joint of xyzypr = {60,45,0,0,45,0}
dim shared jntPlaceLow as joint of xyzypr = {60 , 49.9504 , 0.352258 , 0 , 39.6973 , 0}
dim shared dVelSlow as double = 40.0
dim shared dVelFast as double = 80.0
program
Sys.Vrate = 100.0
with Puma
Attach
En = TRUE
Sleep 100
while NOT En
Sleep 100
end while
Move jntZeroPosition Vcruise=dVelSlow
call waitMotion
call pickPlaceJoint
Move jntZeroPosition Vcruise=dVelSlow
call waitMotion
Detach
end with
end program
sub pickPlaceJoint
dim i as long
dim dVelFac as double = 0.9
Move PUMA jntZeroPosition Vcruise=dVelSlow
call waitMotion
Move PUMA jntPickHigh Vcruise=dVelSlow
call waitMotion
Puma.BlendingMethod = 1
Puma.Cp = 50
puma.J1.PeMax = 3.0 ' 0.2
for i = 1 to 10
Move Puma jntPickHigh Vcruise = PUMA.Vmax * dVelFac
Move Puma jntPickLow Vcruise = PUMA.Vmax
call waitMotion
Move Puma jntPickHigh Vcruise = PUMA.Vmax
Move Puma jntPlaceHigh Vcruise = PUMA.Vmax * dVelFac
Move Puma jntPlaceLow Vcruise = PUMA.Vmax
call waitMotion
Move Puma jntPlaceHigh Vcruise = PUMA.Vmax
next i
Move PUMA jntZeroPosition Vcruise = dVelSlow
call waitMotion
end sub
sub waitMotion
while puma.IsMoving
Sleep 1
end while
end sub