
Dunning-Kruger

Below is a simple code I hacked up to use with the voice recognition control... It works as expected... I am controlling the robot via voice mostly, but sometimes i want it to roam autonomously (as per my simple code below). However, problem is I can't figure out how to exit the script at will... Once this script starts it only stops when the ping detects an object... Ideally, I would like to take back control of the robot at any time... So my question is, how do I break out of the control loop using a voice command or any other way for that matter? By the way, the script has no name because it is within the voice command control...
Say("Forward slowly")
SendSerial(D0, 38400, 161)
SendSerial(D0, 38400, 93)
:loop
$fping=getping(D7,D7) #using a SRF05 sonar with echo and trigger on the same pin
if($fping<15)
say("Object close by, stopping")
SendSerial(D0, 38400, 0)
SendSerial(D0, 38400, 0)
Halt()
endif
goto(loop)
Upgrade to ARC Pro
Get access to the latest features and updates with ARC Early Access edition. You'll have everything that's needed to unleash your robot's potential!
Zargos.EZB
Code:
Then in your main script, periodically check the abort variable, you could do this by throwing in;
Code:
Or you could combine it with the ping checking;
Code:
Just a couple of ideas off the top of my head
Use script manager for the scripts then just ControlCommand() to start the script with the correct voice command. Have another voice command of abort which ControlCommand() to stop all scripts.
Code:
Simple
All variables are global. I.E. If you have script a;
Code:
script b;
Code:
and script c;
Code:
Run script a, then b, then c. Script C will print "hello world".
Note: Script a and b have no need to loop really since nothing is changing but it filled out the code a bit
So, with that in mind, having a voice command which has a script of
Code:
Will set the global variable $abort to 1. All other scripts know this. So if the if statement I posted for the abort is in the code and gets run periodically it will abort. Your script looks like it runs very fast so would know about the abort in a matter of milliseconds.
Otherwise, you could just keep pasting that if statement in to the code throughout, if it was a longer script. Or better still use a label and goto
Code:
Here are the release notes which addresses your issue: http://www.ez-robot.com/Community/Forum/posts.aspx?threadId=5044
Just means DJ is going to get more of my freekin' money....:D
Thanks DJ and Rich