robot arm experiment


robot arm dimension  (unit is pixel unit)

shoulder --- elbow --- wrist --- tip

L1 = shoulder to elbow 74
L2 = elbow to wrist 68
L3 = wrist to tip 24
arm width  14

range limit (degree)   
step size 5
shoulder  180    
elbow 180
wrist  180

working area (pixel unit)

width 250
height 200

initially shoulder is at 33, 128
en0 has one box 180,60,30,20, target 169,22
(box x,y,w,h)
target tolerance  10  (it is distance ^ 2)

GP parameters

terminal symbol    
SP SM EP EM WP WM     
  joint motion  sh+, sh- etc.
HITQ SEEQ INCQ DECQ OUTQ   
  sensing:  hit?  see?  inc? (distance tip to target) dec?
  out? (out of bound)

function symbol
IFAND IFOR IFNOT
  if-and a b dotrue dofalse
  if-or a b dotrue dofalse
  if-not a dotrue dofalse

where a, b, dotrue, dofalse are sub-tree

GP run

population size 400
individual length is first generation  > 40 nodes
maximum generation 40
genetic operator
  crossover   200
  mutation by addition (add at root)  100
  mutation by extension (add at leaf) 200
each mutation generate tree of depth 1

fitness function

fit = -2000*lastdist/initdist
      - 100*sumdist/initdist
      -1000*seeF -4000*dieF

lastdist/initdist   indicates how close the tip to the target
sumdist/initdist    indicates the distance the robot moved
seeF                there is no obstacles between the tip and the target
dieF                early termination (because robot get stuck)

individual encoding (to output/input from a file)

a  b  c  d ....                                       n
0  1  2  3 .....                                      13
SP SM EP EM WP WM HITQ SEEQ INCQ DECQ OUTQ IFAND IFOR IFNOT

Example of output from a typical run

gen 1 best fit -755 av fit -2484 av len 54
gen 2 best fit -755 av fit -811 av len 49
gen 3 best fit -755 av fit -785 av len 50
gen 4 best fit -755 av fit -760 av len 53
gen 5 best fit -752 av fit -754 av len 45
gen 6 best fit -736 av fit -753 av len 45
gen 7 best fit -736 av fit -750 av len 47
gen 8 best fit -736 av fit -742 av len 54
gen 9 best fit -736 av fit -736 av len 56
pgm 0 len 64 fit -733 time 21 success 1 dist 162
: nmngmmjgbfllhjnggkanmgljlahidgkmameifmlicagjfkaiddknihdghgejibkg
pgm 1 len 60 fit -736 time 22 success 1 dist 12395
: ngmngmmjgbfllhjnggkanmgljagkmameifmlicahjfkaidaknihdghgejibe
pgm 2 len 60 fit -736 time 22 success 1 dist 12480
: nmngmmjgbfllhjnggkanmgljagkmameifmlicagjfkaidaknihdghgejibkg
pgm 3 len 38 fit -736 time 22 success 1 dist 12565
: mjngmmjgbfllhjnggkanmgljagkgdakkghgekb
pgm 4 len 57 fit -736 time 22 success 1 dist 12625
: mngmmjgbfllhjnggkanmgljagkmameifmlicahjfkaidaknihdghgejib
....  

the first 9 lines shows fitness from each generation
then the best individual (40), its attribute and the program tree

I also modify program to read input of individual from a file and output the trace (a movie) of a simulation of each individual in terms of coordinate (in pixel unit)

Example

 The input file is:
nmngmmjgbfllhjnggkanmgljlahidgkmameifmlicagjfkaiddknihdghgejibkg
ngmngmmjgbfllhjnggkanmgljagkmameifmlicahjfkaidaknihdghgejibe

the output is (this is for the first individual):

no of prog 2
102 101 150 53 161 33
102 101 150 54 162 34
101 99 149 51 161 31
101 99 149 52 161 32
100 96 148 48 160 28
100 96 148 49 160 29
98 94 146 46 158 26
97 92 144 44 156 24
96 89 142 40 154 20
95 87 140 37 152 17
93 85 137 34 149 14
93 85 138 35 151 16
93 85 139 36 152 17
93 85 140 37 154 18
93 85 141 37 155 18
93 85 141 38 155 20
93 85 142 39 157 21
93 85 143 40 158 22
93 85 144 41 159 23
93 85 145 42 161 25
pgm 0 finishF 1 dieF 0 seeF 1 pain 0 fit -733 clock 21 len 64 dist 162

each line is (elbow.x elbow.y wrist.x wrist.y tip.x tip.y)
shoulder is at 33, 128

24 Feb 2006