Universal Robots Forum

How to control a Thread between URCaps

I have two URCaps (lets say X and Y) and movement nodes between them. The move nodes are related to the URcap X, but not the child nodes. Under certain conditions relative to the first URCap, the movement is stopped while moving. The URcaps X and Y are used many times throughout the program tree

To achieve this function i am using Threads and the process is working, but the thread is continuously running for the whole Program Tree. The expected behavior is the thread to end when the URCap X and the related move nodes ends (before the Y URCap starts).
I do not want to check the condition to the program nodes which are not related to the URCap X. I tried killing the Thread, but still no use.

Any help would be very much appreciated.
Thank you, in advance.

1 Like

I have been using threads recently with Java, using the implements runnable. Once the thread is started inside the run function I have an atomic boolean condition that keeps a while loop running, whenever I need to kill the thread I change the condition and it exits the run function.

Thank you for your response.
I am using URScript, but sure I will check this option too.

Hi,

Can you send me a code sample please?

Thanks in advance.

I thought you had been programming URCaps and were running threads within those. For using threads when scripting I recommend checking out the script manual and looking at the documentation for threads. https://s3-eu-west-1.amazonaws.com/ur-support-site/53318/scriptManual.pdf

You are right. Just by changing the conditions it worked.
Thanks.

1 Like

Is it possible to start a Thread from X URCap and kill the same Thread using Y URCap?

If X URCap wrote the thread, running continuously off a global variable and Y URCap changed variable to turn off thread it sounds like it would work.

1 Like