In threaded child script call another child script to run again

Typically: "How do I... ", "How can I... " questions
Post Reply
ariyayi
Posts: 16
Joined: 05 May 2018, 13:25

In threaded child script call another child script to run again

Post by ariyayi » 29 May 2018, 17:07

hello,

In my robot path planning algorithm that run in threaded child script(khepera robot) suppose from initial position to goal position robot stop in 5 step to find next position to achieve the goal position. I need "hokuyo urg 04lx ug01" sensor output that run in threaded child script . I change "hokuyo urg 04lx ug01" Non-Threaded child script to threaded child script because It's not always necessary to check for obstacle in my work.
so I need to call "hokuyo urg 04lx ug01" child script run when I want before each step in khepera robot threaded child script. How can i do it?
In addition I use sim.setStringSignal to send data from "hokuyo urg 04lx ug01" child script to khepera robot threaded child script and it works.

thanks,

fferri
Posts: 408
Joined: 09 Sep 2013, 19:28

Re: In threaded child script call another child script to run again

Post by fferri » 29 May 2018, 18:38

how would you identify when the robot has to stop?

do you repeatedly check if the robot's position is close to some landmark (i.e. their distance is below some threshold)?

ariyayi
Posts: 16
Joined: 05 May 2018, 13:25

Re: In threaded child script call another child script to run again

Post by ariyayi » 29 May 2018, 20:50

Yes, exactly

fferri
Posts: 408
Joined: 09 Sep 2013, 19:28

Re: In threaded child script call another child script to run again

Post by fferri » 29 May 2018, 22:54

you can consider setting a boolean signal to true from the robot script, that will trigger obstacle detection in the sensor's script i.e. you repeatedly check if this signal value is true and if so start the computation, and set the signal value back to false after that

ariyayi
Posts: 16
Joined: 05 May 2018, 13:25

Re: In threaded child script call another child script to run again

Post by ariyayi » 30 May 2018, 23:56

I disabled sensor script and put all codes in function and copy all in robot script out of function sysCall_threadmain()

Robot script

Code: Select all

Function laser()
All sensor script code
Return x
End

function sysCall_threadmain()
Call laser
End

In this way when l call laser() in while loop it works, is it correct ? Or may cause time complexity or conflict ?

fferri
Posts: 408
Joined: 09 Sep 2013, 19:28

Re: In threaded child script call another child script to run again

Post by fferri » 31 May 2018, 08:48

looks good!

Post Reply