
I have a few scripts that don't do what they are suppose to do until I run thru them once. Let me explain that - in the script below the robot is doing addition. What should happen is, for example, when I say "two" the robot should look at it's hand, extend 2 fingers and say "two" and when I say "plus four" the robot should look at it's other hand, extend 4 fingers and say "add four". What is happening is the robot is looking where it should and saying what it should but not extending the fingers. It does the addition part correctly and returns to the start of the script. Then given the commands again everything runs properly. It may be something I'm doing in my scripting because this happens in a couple of other scripts I have written. I would appreciate any thoughts on how to solve this problem. Thanks
Sayezb("ok, I like doing math")
sleep(500)
ControlCommand("Script Manager", ScriptStart, "Do math")
sleep(4000)
sayezb("ready")
:start
$heard = "speech"
WaitForChange($heard)
if($Heard = "one")
$x = 1
elseif($heard="two")
$x = 2
elseif($heard ="three")
$x = 3
elseif($heard = "four")
$x = 4
elseif($heard = "five")
$x = 5
endif
WaitForChange($heard)
if($heard = "plus one")
$y = 1
elseif($heard = "plus two")
$y = 2
elseif($heard ="plus three")
$y = 3
elseif($heard ="plus four")
$y = 4
elseif($heard = "plus five")
$y = 5
#print($x + $y)
endif
WaitForChange($heard)
if($heard = "what does that equal")
servo(d0,150)
servospeed(d0,3)
servo(d1,90)
servospeed(d1,3)
sayezb("ummm")
ControlCommand("Script Manager", ScriptStart, "Close right Hand")
ControlCommand("Script Manager", ScriptStart, "Close left hand")
Sleep(1500)
Servo(d0,116)
servospeed(d0,3)
servo(d1,118)
servospeed(d1,3)
sleep(1500)
$sum = Abs($x + $y)
Sayezb($x + " plus " + $y + " equals " + $sum)
endif
if($sum = 2)
ControlCommand("Script Manager", ScriptStart, "equals two")
elseif($sum = 3)
ControlCommand("Script Manager", ScriptStart, "equals three")
elseif($sum = 4)
ControlCommand("Script Manager", ScriptStart, "equals four")
elseif($sum = 5)
ControlCommand("Script Manager", ScriptStart, "equals five")
elseif($sum = 6)
ControlCommand("Script Manager", ScriptStart, "equals six")
elseif($sum = 7)
ControlCommand("Script Manager", ScriptStart, "equals seven")
elseif($sum =8)
ControlCommand("Script Manager", ScriptStart, "equals seven")
elseif($sum = 9)
ControlCommand("Script Manager", ScriptStart, "equals nine")
elseif($sum = 10)
ControlCommand("Script Manager", ScriptStart, "equals ten")
endif
sleep(4000)
ControlCommand("Script Manager", ScriptStart, "Close right Hand")
ControlCommand("Script Manager", ScriptStart, "Close left hand")
Sleep(500)
GoTo(start)
WaitForChange($HEARD) I also tried ControlCommand("Script Manager", ScriptStop,"TheScriptName") and that didn't make any difference.
Hey Bob... I am late to the party and may be way off base but.... I do notice in my own scripts that sometimes when I release servos or set them using Servo(D0,0) they won't respond to another position command at first... Sometimes I need to reset servo speed again to 0 and then to another speed that I wanted before they would respond again...
I think that what richard is saying is probably the issue. Maybe setting all of the hand servos before starting the math script ( at the top of this script) would solve this for you.
Good idea Richard, I set all of the finger servo speeds to 0 and that seems to have solved the problem. In another script, I had to do it twice. It seems I have to do this after a CC or an AutoPosition that sets the fingers to a certain position.
Thanks to both of you for your help.
@Bob.... Hey I got lucky.... LOL. How is the lower stomach mechanism coming along? I still plan to do mine, but I actually started a part time job so I have a little less free time than I use to have...