Streaming function. Multiple functions.
Posted: 25 Sep 2021, 18:27
This is a multi-threaded script (part of the coroutine Main ())
I need to loop my workflow. But the next step should only be performed when the isnextTest variable becomes true. I try to read at every step of the StringSignal loop, which contains an array with an array of bool type representing the readiness of the drones, and if all the values of the array == true, then the operations in the loop can start again. But this check for some reason goes beyond the time frame and everything crashes.
I will give a part of the code where I am trying to do this:
maybe I'm doing something wrong. Or do I need a separate multi-threaded function where I can check safely? Help me please!!
If possible please insert a short pseudocode into my patch code.
I need to loop my workflow. But the next step should only be performed when the isnextTest variable becomes true. I try to read at every step of the StringSignal loop, which contains an array with an array of bool type representing the readiness of the drones, and if all the values of the array == true, then the operations in the loop can start again. But this check for some reason goes beyond the time frame and everything crashes.
I will give a part of the code where I am trying to do this:
Code: Select all
function coroutineMain()
-- my initialization...
while true do
local testssolved=0
if testssolved>0 and waitingforNextTest() then
if Testcount>0 then
--my functions are executed, which needs to be looped
sim.switchThread()
else
print("END!!!!!!!!!!!!")
end
end
end
end
--somewhere below one of my functions...
function waitingforNextTest()
for i=1,#quadcopters,1 do
local copterscript=sim.getScriptAssociatedWithObject(quadcopters[i])
local isAtstartpoint=sim.callScriptFunction("isAtstartpoint@"..sim.getScriptName(copterscript),copterscript,isAtstartpoint)
if isAtstartpoint==false then
return false
end
end
return true
end
maybe I'm doing something wrong. Or do I need a separate multi-threaded function where I can check safely? Help me please!!
If possible please insert a short pseudocode into my patch code.