
Lonesoulsurfer
Hello all,
I've just put together a script which makes makes my robot do a little panic dance when I say "danger" (thanks Hazbot for the sample - I used it for some inspiration)
If you have a look at the video below he moves his arms, turns his head and does a little jiggle.
The problem is I had to open 3 script windows and add each movement into each one to make it work. What I want to be able to do is stick all of the script into one window.
When I tried this the movements didn't happen altogether but separatly.
In the first script window I put the following:
ControlCommand("danger", ScriptStart)
ControlCommand("danger2", ScriptStart)
ControlCommand("danger3", ScriptStart)
Say("tomy danger")
This made all of the "danger" scripts activate together.
Now I'm a total novice at doing all of this and I'm really just bumbling my way through at the moment so any help (or samples) would be appreciated.
Also, all the commands in the script are just repeated over and over to get the movement, is there any way that you can repeat an action say 4 times, so you don't have these humongously long scripts?
Thanks all.
Hazbot
As for what you're trying to do.... Require either a delay, or chain scripts together. The command is "scriptStart" that you are sending. That means "start script"
ControlCommand( "Blink", ScriptStart, wait, # secs) where wait could be 0 = no-wait or 1 = wait and # secs the number of seconds to wait for script to end ?
Greetz,
PhG
You should be able to put all the commands into one script and tweak
with "Sleep" commands for delays.
It would be vary basic like this:
Voice Command: "Tomy Danger"
Executes Script: "DangerDance"
DangerDance Script
# Dance Script (Repeats 4 Times)
# Stops Random Script and/or any other scripts not required
ControlCommand("TomyRandom", ScriptStop)
# Dance Sequence - 1
ServoRandom (D14,40,70)
Sleep(500)
Release(D14)
Sleep(500)
# Call Blink script
ControlCommand("Tomy-Blink", ScriptStart)
Sleep(500)
# Dance Sequence - 2
ServoRandom (D14,40,70)
Sleep(500)
Release(D14)
Sleep(500)
# Call Blink script
ControlCommand("Tomy-Blink", ScriptStart)
Sleep(500)
# Dance Sequence - 3
ServoRandom (D14,40,70)
Sleep(500)
Release(D14)
Sleep(500)
# Call Blink script
ControlCommand("Tomy-Blink", ScriptStart)
# Dance Sequence - 4
ServoRandom (D14,40,70)
Sleep(500)
Release(D14)
Sleep(500)
# Call Blink script
ControlCommand("Tomy-Blink", ScriptStart)
# Script finished. Reset head/arms/eyes/audio back to neutral
ControlCommand("TomyInit", ScriptStart)
Sleep(500)
# Restart random script
ControlCommand("TomyRandom", ScriptStart)
I use the ControlCommand ScriptStart and ScriptStop quite a bit for various functions.
Typically If I'm starting a special voice command, I will stop all random scripts, random
audio, stop all movement, then execute the special script I want. Once the script is
complete I reinitialize and return head/arms/eyes back to a neutral position and re-start
my random script.
If I do call another script from within a script it is normally setup to just run once. I call it
again if required. Using sleep and sleeprandom to mix things up.
Building upon this, if you use the wiggly arm movements for something else, I'd make
it a seperate script. Call it the 4 times required for your dance routine. Nothing wrong with having multiple scripts.
Hope this helps. Linking scripts is easy and fun. I try to find the best way to minimize the
amount of scripts required. Trying to teach myself C++/C# to go to the next level.
Any questions just ask.
Voice Command: "Tomy Danger"
Executes Script: "DangerDanceRun"
DangerDanceRun Script
# Runs DangerDance Script (Repeats 4 Times)
# Stops Random Script and/or any other scripts not required
ControlCommand("TomyRandom", ScriptStop)
# Dance Sequence - 1
ControlCommand("DangerDance", ScriptStart)
Sleep(4000)
# Dance Sequence - 2
ControlCommand("DangerDance", ScriptStart)
Sleep(4000)
# Dance Sequence - 3
ControlCommand("DangerDance", ScriptStart)
Sleep(4000)
# Dance Sequence - 4
ControlCommand("DangerDance", ScriptStart)
Sleep(4000)
# Script finished. Reset head/arms/eyes/audio back to neutral
ControlCommand("TomyInit", ScriptStart)
Sleep(500)
# Restart random script
ControlCommand("TomyRandom", ScriptStart)
Your DangerDance script would contain the dance routine.
DangerDance Script
# Dance Sequence
ServoRandom (D14,40,70)
Sleep(500)
Release(D14)
Sleep(500)
# Call Blink script
ControlCommand("Tomy-Blink", ScriptStart)
Sleep(500)
ServoRandom (D13,40,70)
Sleep(500)
Release(D13)
Sleep(500)
The secret is to tinker and play with the sleep command for timing.
Thanks Lumpy for all of your suggestions. I have posted the script in the EZ cloud / Examples / Robot in Danger.
I'm going to have a play later tonight and see where I can improve it. I especially like your idea of keeping them separate so you can use them in different routines - makes total sense.
cheers.
Cheers
Code:
This new ControlCommand() will wait until the specified script has completed before continueing. You can find examples of it being used in the File->Examples folder within ARC.