Difference between revisions of "Program Examples - Robot Pick and Place (P&P)"

From SoftMC-Wiki
Jump to: navigation, search
Line 1: Line 1:
here is an example of doing Robot Pick and Place. we we use puma 6 axis robot in this example:
+
here is an example of doing Robot Pick and Place. We use puma 6 axis robot in this example:
  
  
Line 6: Line 6:
 
'------------------------------------------------------------------------------
 
'------------------------------------------------------------------------------
 
' File:        PnP.prg
 
' File:        PnP.prg
' Purpose:    generating circle contour with a puma robot
+
' Purpose:    Robot simple Pick & Place
 
' Version:    1.00
 
' Version:    1.00
' Author:      Or KArni
+
' Author:      Or Karni
 
' History:    11.JAN.2017 - created
 
' History:    11.JAN.2017 - created
 
'------------------------------------------------------------------------------
 
'------------------------------------------------------------------------------
  
 
dim shared jntZeroPosition as joint of xyzypr = {0,0,0,0,0,0}
 
dim shared jntZeroPosition as joint of xyzypr = {0,0,0,0,0,0}
dim shared locCircleCenter as location of xyzypr =#{1101.57 , 0 , -49.804 , 0 , 180 , 0}
+
 
dim shared locCircleStart as location of xyzypr = #{901.572 , 0 , -49.804 , 0 , 180 , 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
 
program
  
Sys.Vrate = 100.0
+
    Sys.Vrate = 100.0
with Puma
+
    with Puma
Attach
+
        Attach
En = TRUE
+
            En = TRUE
Sleep 100
+
            Sleep 100
while NOT En
+
            while NOT En
Sleep 100
+
                Sleep 100
end while
+
            end while
call circularMotion
+
            Move jntZeroPosition Vcruise=dVelSlow
Detach
+
            call waitMotion
end with
+
              call pickPlaceJoint
 +
            Move jntZeroPosition Vcruise=dVelSlow
 +
            call waitMotion
 +
        Detach
 +
    end with  
  
 
end program
 
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
  
sub circularMotion
 
 
dim dVelSlow as double = 20.0
 
 
Move PUMA locCircleStart Vcruise=dVelSlow
 
call waitMotion
 
Circle PUMA Angle=5*360 CircleCenter = locCircleCenter Vtran = PUMA.VmTran/2
 
call waitMotion
 
Move PUMA jntZeroPosition Vcruise=dVelSlow
 
call waitMotion
 
 
 
end sub
 
end sub
 
 
  
 
sub waitMotion
 
sub waitMotion
while puma.IsMoving
+
    while puma.IsMoving
Sleep 1
+
        Sleep 1
end while
+
    end while
 
end sub
 
end sub
  
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 09:49, 12 January 2017

here is an example of doing Robot Pick and Place. We use puma 6 axis robot in this example:


PnP.PRG:

'------------------------------------------------------------------------------
' File:        PnP.prg
' Purpose:     Robot simple Pick & Place
' Version:     1.00
' Author:      Or Karni
' History:     11.JAN.2017	-	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