You are on page 1of 9

Programming Language/pick and place in KAREL

--Transfer work pieces from one pallet to another


Var
- - Variable for the input pallet
BASE1 : position -- (1,1) position on the pallet
IR1,IC1 : integer -- counter for rows& columns
NR1,NC1 :integer -- limits for rows and cols
DR1,DC1 : vector -- delta between row and cols
ISIG1,OSIG1 :integer -- signal for pallet changing
- - Variables for the output pallet
BASE2 : position -- (1,1) position on the pallet
IR2,IC2 : integer -- counter for rows& columns
NR2,NC2 :integer -- limits for rows and cols
DR2,DC2 : vector -- delta between row and cols
ISIG2,OSIG2 :integer -- signal for pallet changing
Contd.

routine PICK
-- Pick a work piece from the pallet
var
TARGET : position -- target pose
begin
IR1=IR1+1
If IR1>NR1

then
IR1=1
IC1=1+1
If IC1>NC1
Then
IC1=1
-- get a new pallet
dout[OSIG1]=true
-- notify pallet changer
wait for din[ISIG1]+
-- wait for input line to go high
Contd.

-- meaning pallet has been changed


dout[OSIG1]=false
-- turn off our output signal
-- compute target pose
endif
endif
TARGET=BASE1
-- start with (1,1) pose
shift (TARGET,(IR1-1)*DR1+(IC1-1)*DC1)
-- shift for row and col offset
-- get the part
move near TARGET by 50 -- move to 50 mm away from TARGET
move to TARGET
close hand 1
move away 50 -- back away from TARGET by 50 mm
end PICK
Contd.

routine PLACE
-- Place a work piece on the output pallet
var
TARGET : position -- target pose
begin
IR2=IR2+1
If IR2>NR2
then
IR2=1
Contd.

IC2=1+1
If IC2>NC2
Then
IC2=1
-- get a new pallet
dout[OSIG2]=true
-- notify pallet_changer
wait for din[ISIG2]+
-- wait for input line to go high
-- meaning pallet has been changed
dout[OSIG2]=false
-- turn off our output signal
-- compute target pose
endif
endif
TARGET=BASE2
-- start with (1,1) pose
shift (TARGET,(IR2-1)*DR2+(IC2-1)*DC2)
-- shift for row and col offset

move near TARGET by 50 -- move to 50 mm away from TARGET


move to TARGET
open hand 1
move away 50 -- back away from TARGET by 50 mm
end PLACE
Contd.

Main program
begin
IR=0 ;IC1=0
IR2=0;IC2=0
initialize other variable
--
-- BASE1,NR1,NC1,DR1,DC1,ISIG1,OSIG1
--
-- BASE2,NR2,NC2, DR2,DC2,ISIG2,ISOG2
--
-- numerical pose defined omitted here
Open hand1
while true do -- loop
pick
place
endwhile
end PALLET
INDUSTRIAL APPLICATION
Contd.
Contd.

You might also like