Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Hong Kong
Asked — Edited
Resolved Resolved by DJ Sures!

Few Commands Processing As Same Time?

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;)

PRO
Synthiam
#1  
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...
1) never can only the last command execute without previous commands executing. This is because time moves forward, and we can't change that.
2) you provided zero information about what commands you've added

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.
PRO
Synthiam
#2  
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...

Code:


ControlCommand("Auto Position", AutoPositionAction, "Grab")

ControlCommand("Auto Position", AutoPositionAction, "Lunge Singing")

ControlCommand("Auto Position", AutoPositionAction, "Roll Hands")


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...

Code:


ControlCommand("Auto Position", AutoPositionAction, "Grab")

Sleep(2000)

ControlCommand("Auto Position", AutoPositionAction, "Lunge Singing")

Sleep(2000)

ControlCommand("Auto Position", AutoPositionAction, "Roll Hands")


Did the light bulb turn on?:D

Now, once you dive into the available functions to start using logic a little more creatively... you can do this:

Code:


ControlCommand("Auto Position", AutoPositionAction, "Grab")

Sleep(100)
WaitFor($AutoPositionStatus == 0)

ControlCommand("Auto Position", AutoPositionAction, "Lunge Singing")

Sleep(2000)

ControlCommand("Auto Position", AutoPositionAction, "Roll Hands")


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.
PRO
Synthiam
#3  
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...

Code:


ControlCommand("Auto Position", AutoPositionAction, "Grab")

ControlCommand("Auto Position", AutoPositionAction, "Lunge Singing")

ControlCommand("Auto Position", AutoPositionAction, "Roll Hands")


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.
#4  
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
#5  
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.
PRO
Synthiam
#6  
Read my response above - the one including WaitFor(), which will wait for an Auto Position action to complete.