When this program is run, it crashes Aseba. The program can compile. You can load it, but you cannot run it. After it is loaded the program becomes eventually becomes unresponsive. The program does not load properly until the robot is turned off and turned on again and the program is reloaded.
Here is the program: (unfortunately i can't link to the file I have because it says I don't have enough karma)
<!DOCTYPE aesl-source>
<network>
<!list of global events>
<!list of constants>
<!show keywords state>
<keywords flag="true"/>
<!node thymio-II>
<node name="thymio-II">var temp
var rc5_speed_l
var rc5_speed_t
- proximity speed
var use_prox
var prox_speed_t
var vmin=-600
var vmax=600
var led_pulse
timer.period[0]=20
sub setmotor
if use_prox == 1 then
motor.left.target = prox_speed_t
motor.right.target = - prox_speed_t
else
call math.min(rc5_speed_t, rc5_speed_t, vmax)
call math.max(rc5_speed_t, rc5_speed_t, vmin)
call math.min(rc5_speed_l, rc5_speed_l, vmax)
call math.max(rc5_speed_l, rc5_speed_l, vmin)
motor.left.target = rc5_speed_l + rc5_speed_t
motor.right.target = rc5_speed_l - rc5_speed_t
end
onevent button.left
if button.left==1 then
rc5_speed_t = -200
end
callsub setmotor
onevent button.right
if button.right==1 then
rc5_speed_t = 200
end
callsub setmotor
onevent button.center
if button.center==1 then
rc5_speed_t=0
rc5_speed_l=0
end
callsub setmotor
onevent button.backward
if button.backward==1 then
if rc5_speed_t !=0 then
rc5_speed_t = 0
else
rc5_speed_l = rc5_speed_l-200
end
end
callsub setmotor
onevent button.forward
if button.forward==1 then
if rc5_speed_t !=0 then
rc5_speed_t = 0
else
rc5_speed_l = rc5_speed_l+200
end
end
callsub setmotor
onevent buttons
when button.backward==1 and button.forward==1 do
rc5_speed_l = 0
end
when button.right==1 and button.left==1 do
rc5_speed_t = 0
end
callsub setmotor
onevent timer0
#Body color pulse
led_pulse = led_pulse + 1
if led_pulse > 0 then
call leds.top(led_pulse,0 , led_pulse)
if led_pulse > 40 then
led_pulse = -64
end
else
temp=-led_pulse/2
call leds.top(temp, 0, temp)
end
onevent rc5
if rc5.command !=0 then
if rc5.command == 2 then
if rc5_speed_t!=0 then
rc5_speed_t = 0
else
rc5_speed_l = rc5_speed_l+200
end
elseif rc5.command == 4 then
rc5_speed_t = -200
elseif rc5.command == 8 then
if rc5_speed_t!=0 then
rc5_speed_t = 0
else
rc5_speed_l = rc5_speed_l-200
end
elseif rc5.command == 6 then
rc5_speed_t = 200
elseif rc5.command == 5 then
rc5_speed_t = 0
rc5_speed_l = 0
end
rc5.command = 0
end
onevent prox
if prox.horizontal[2] > 1000 then
# if use_prox = 0 loading of the program works
use_prox = 1
if prox.horizontal[1] > prox.horizontal[3] then
prox_speed_t = 200
else
prox_speed_t = -200
end
else
use_prox = 0
end
callsub setmotor
</node>
</network>