Asked
— Edited
Resolved by DJ Sures!
Hi,
I put few command lines from the Cheat Sheet in Audio - Speech Recognition. But it just run the script one by one. Sometimes, it just run last script.
Anyone know, how to set the script that can process serval command lines as same time?
Thanks for your attention!
B. Regards Ricky Ma
A script, a computer, time, causality, everything in existence... Runs in sequence. There is no such thing as "at the same time".
The philosophy of "at the same time" is perspective. Humans perceive quite slow - in comparison to a measuring instrument designed for a specific task, anyway. That being said, all causality can be measured and identified as specific events. Of course, quantum laws state that no events have occurred until the result has been observed. Observing collapses the wave of potential.
Well, in your case the result is being observed. So...
I can speculate that you added a bunch of Auto Position actions to a single script. And I suspect you imagine that will run in order? But you haven't thought out that each command just runs... And they don't wait. So yes, your last Auto Position will run, and so did all the others. The fact is, the others started and moved on to the next before having a chance to do anything.
The solution? Add a sleep() between Auto Position commands to give them time to actually do something.
Or, investigate options like using the waitfor($autopositionstatus=0)
I would recommend you start learning programming with RoboScratch - it was created to reach people how to program.
Here's some additional information - which you will discover as well using RoboScratch, because it's a good way to start learning to program.
If your code looked like this...
What do you think would happen? Well, Roll Hands would execute, and nothing else. Actually, that's what you perceive happened, when in actuality they all execute but the last command appeared to execute because it was the last command... Make sense?
So what you would want to do is this...
Did the light bulb turn on?
Now, once you dive into the available functions to start using logic a little more creatively... you can do this:
But, you might ask "why didn't you use WaitFor() for the other actions?"
The answer is simple... the other actions are set to repeat, which means they have no end. They will never, ever stop unless you tell the Auto Position to do something else. So WaitFor() would wait for ever, or until another script told the Auto Position to stop.
Lastly - this seems to come up a few times lately - and in other threads regarding the speech recognition or scripting. But people are not paying attention to the log information presented by controls...
You can debug what is happening with the Auto Position, for example, by looking at the Auto Position debug console. It displays everything it is doing. So if you assume the speech recognition is "not executing something", check the Auto Position console to see if it actually is. It will display, in human readable form, the Auto Position action that was executed.
So if you executed...
The Auto Position debug console will display each of those actions... which tells you, they executed but had no time for you, as a human, and for the servos, to execute any frames. This is because there is no time between each action.
Hi DJ,
I am making the human robot facial expression and I have tried to set the "sleep()" script between the command lines before. But, The voice is little bit not sync with the servo movement. So, I have upon question!
Anyway, thanks and appreciated for your answer!
Ricky Ma
Hey @rickymahk2013 you ever get this to sync correctly? I'm asking because we are now working on an inmoov and I've seen your robot and would like understand how you got this working better.
Read my response above - the one including WaitFor(), which will wait for an Auto Position action to complete.