Course: 91.548 Robots 2003 Spring
Student: Jianping Zhou
Instructor: Prof. Fred Martin
Botfes Project
Mr. Worm Jackson
(picture set)
Mr. Worm Jackson
For the current version project, the frame of Mr. Worm is made of Lego bricks; hardware is handy cricket and compatible position switch. Total four crickets are used, one as master, three as slaves. The master is in charge of sampling sound signal in an interval of 0.5 second for standby state, 2 seconds for active state, and selecting the combination of segment controls according to the sampled sound level from a predefined pattern dataset, finally sending control signals to all slaves through its IR channel. The three slave crickets individually monitor their left and right end position switches,as well as control the rotations of their lego motor in response to control signals sent from master and local end position switch signals
Even though I gave up the modularity implementation, I still used the segment built for above purpose as the base segment of current version. Constructing the segment took me several hours to work out in the condition of limited available Lego parts. It has a sturdy and well balanced kinetic gear transmission structure with a ratio 1: 7.3
(picture 2)
Base segment gear transmission set picture
Since the Lego are not intended for position control, its time control cannot guarantee it rotate at fixed angle for same time elapse. At the beginning when I considered this problem, I tried to use one position switch to make segment hold in the center position when the motor power is removed (see illustration).
Since the toy doesn’t care whether the left swing and right swing are precisely equal, but it does need at least one poison to be controlled, e.g. the switch position, for preventing from the accumulated rotation error, therefore this approach will not make the toy wild. Unfortunately the Lego motor doesn’t have constant brake, so this approach only works in the condition that the friction of gear transmission set is big enough to prevent the segments rotate due to gravity of any parts above it when the motor doesn’t have power. Through experiment, I felt very difficult to reach this point since the lab conditions. Finally I used two position switches for leftmost and rightmost end positions separately. In this approach, the time control is still used for swing segment, even the holding of segment, which is a tiny swing cycle instead of removal of motor power. When the accumulation error makes the segment reach the end switch, the system control makes a correction, which forces the swing center to the segment position center. For a reward of this approach due to time control, we get an extra amusing factor, named swing strength or amplitude. It can also correspond to certain sound level. This approach indeed increase the fun of Mr. Worm although the control procedures become more complicated, which costs using up to 5 state variables.
Followings are Mr. Worm Jackson’s anatomy diagram, separate slave code, and master code for the latest version.
Structure diagram of Mr. Worm Jakson
Two comments are mentioned for the code development. All are for the sake of efficiency
1. using a single byte to encode slave id, expected hold position, and swing strength, the format is
ir: - - -- -- - -
idpositionstrength
position -- expected hold position; 0 - center, 1 - leftother - right
strength -- swing amplitude
2. using ifelse instead of if although the codes are less readable.
;;;; slave 1
glabal[data
strength count first right position]
;;;ir: - - -- -- - -
;;;idpositionstrength
;;;
position -- expected hold position 0 - center, 1 - leftother
- right
;;;
strength -- swing am
to
go
setstrength
0
setposition
0
setfirst
1
setright
1
when
[newir?]
[setdata
ir
if (leftshift data -5) = 1
[setstrength (leftshift (leftshift data 13) -13)
setposition (leftshift (leftshift data 11) -14)
setfirst 1
setright 1]]
loop
[ifelse
strength=0
[ifelse switcha
[ifelse position = 0
[goright 5]
[ifelse position = 1
[goright 2]
[goright 7]]]
[ifelse switchb
[ifelse position = 0
[goleft 5]
[ifelse position = 1
[goleft 2]
[goleft 7]]]
[ifelse right = 1
[goright 1 setright 0]
[goleft 1 setright 1]]]]
[ifelse switcha
[goright 2*strength+2 setfirst 0 setright 0]
[ifelse switchb
[goleft 2*strength+2 setfirst 0 setright 1]
[ifelse right = 1
[ifelse first =1
[goright strength setfirst 0 setright 0]
[goright 2*strength setright 0]]
[ifelse first =1
[goleft strength setfirst 0 setright 1]
[goleft 2*strength setright 1]]]]]
end
to
goright :distance
setcount
0
a,
setpower 8 thisway on
loop
[ifelse switcha or (count > :distance) [brake stop] [wait 1 setcount 1+count]]
end
to
goleft :distance
setcount
0
a,
setpower 8 thatway on
loop
[ifelse switchb or (count > :distance) [brake stop] [wait 1 setcount 1+count]]
end
;;;;master—detector
and commander
global
[sample]
to
go
loop
[setsample
sensora
ifelse sample < 5 [send $20 beep wait 2
send $40 beep wait 2
send $60 beep wait 2]
[ifelse sample < 5 [send $20 beep wait 2
send $40 beep wait 2
send $60 beep wait 2]
[[send $27 beep wait 2
send $47 beep wait 2
send $67 beep wait 2]]]]
ifelse sample < 5 [wait 5][wait 30]
]
end
2/28/03Constructed and experimented the one position switch approach. Failed
2/4/03Reached the current version structure
2/11/03Developed the code