Hi all,
I am communicating with the UR5e robot via port 30003 using URScript in python.
I have successfully managed to move the robot in the desired way, but now I am trying to implement a thread that will open a gripper (RG2 OnRobot) before the robot moves.
I am not sure how to implement a thread in python, and I did not succeed in finding information on the forum regarding this issue.
Inside my main function code, I have defined the Thread function, which supposes to open the gripper.
Any suggestions on how can I get it to work? Can a thread be defined as any function with any name? Does it need to be located in a special place in the code?
Is this question related to this one: URScipt + robot code ?
In the script manual you can see how to write a thread in your URScript. Making a python thread will only help you if you put the gripper functionality into the secondary program(remeber to disable the blocking functionality to reduse the time consumption).
@Ebbe Yes it is related to the other post I made, though it asks about slightly different approach. I the other post I am not interested in sending two programs via TCP/IP communication but rather to run one thats already defined on the robot and one thats beeing send from PC
I saw in the manuall how to write a thread
But I have no idea how to implement it in python.
Any suggestions?
The syntax of a thread is simlar to standard fuction definition syntax in python, as can be seen on the screenshot I attached initially, calling a function in the main code, doesnt treat it like a thread
The difference is that you have to use the keyword thread instead of def. When you want to start the thread, do as stated in the documentation:
thrd = run myThread()
myThread will then run parallel with you program and thrd is our handle to the thread. You can use it for joining or killing the thread.
Regarding python. You shall consider if you are sending the primary or secondary program to the robot. Please note that you shall limit the amount of physical time you are using in the secondary program.
@Ebbe
The keyword thread is undefined when using python so I cant use it.
I am looking for how to run thread using python and I do not seem to find any relevant documentation regarding this topic