I have written while loop for the robot via a teaching pendant that checks all the time if the digital_out[0] is True or False and then depending on the outcome, performs some action.
I also have my PC connected to the robot and I communicate via port 30003 where I send a command to set the digital out[0] to either True or False.
The issue I am having is that once I run the code using python and the communication via socket, the code that was defined via a teaching pendant doesn’t run.
Thank you, @Ebbe
However, I am looking for an option of running a program that was coded on the robot, and then to change a variable defined in that code using an external URScript which is sent to robot via port 30003.
Do you know if I can run both the URScript and the already programmed program at the same time ?
Yes. As long as the secondary code is simple enough. If you look up the script manual section 1.10 it describes how to run secondary programs, the limitations, and requirements they must meet.
If you only need to change an output then the following example from the same section will do:
sec secondaryProgram():
set_digital_out(1,True)
end
EDIT: I don’t think you can change a variable in the other script but you can use the built-in registers as a variable and set that with a secondary program.
Whenever I run the program on the teaching pendant, and I also run a second program from PC, the program that was running on the teaching pedant stops running and only the PC Script is run.
Do you know how can I run the script from PC so it wont stop the script from teaching pendant?
It includes sample python code at the bottom of the article and you can name the registers in the I/O setup menu in Polyscope to use them directly in your program.
@ajp
I have a script where commands are executed in real-time (RTDE) via my PC . Because I am using an OnRobot gripper and I am unable to operate it from the PC script (there have been some issues with OnRobot communication), I thought of writting a program on the Polyscope that loops all the time, and opens/ closes the gripper when specific variable is True/False.
The issue of mine is that when I first run the program on the polyscope and then run a second program using my PC, when the connection between PC and robot is established the initial program that was created on polyscope is terminated and only the connection via PC is taken into account.
Thus I am looking to communicate a variable change to a running program which I know how to do. The issue again is the fact that when I do change the variable in the running program, that should trigger an action that was defined on the plyscope, but that doesnt happen,
I don’t think you can directly modify variables defined in the main program from a secondary program, they don’t exist within the same scope. I’d still use the RTDE registers here, if you want to do it with a secondary program then you could use write_output_boolean_register() in there instead.
The above wouldn’t explain why your main program is being terminated though. Can you post exactly what you’re sending? Secondary program is not allowed to use any physical time, so no waits, syncs, moves, anything like that. Just a set/write command.
So when the script is sent from my PC to the robot, the I/O is changed which I can see on the screen in a similar manner as in step 2) howeveer because the polyscope code is not running, the gripper doesnt open/close
If you just send the set command the controller will treat it as a primary program and terminate the existing primary program. You need to wrap it in the secondary program definition. Easy way to do this for a multiline script function is with triple quotes:
secprog="""
sec secondaryProgram():
set_standard_digital_out(1, True)
end
“”"
s.send(secprog)
Just out of curiosity, do you know if there is a way to reverse the situation ie. instead of polyscope program to be a primary program and the python script to run as a secondary, how could I run the python script as primary and the polsycope as a secondary?
Hello UR Technical Support,
How can I get the running status back from the UR robot while running the script after sending the .script file over the Primary or secondary port (30001 or 30002)? OR how to send the .script file on RTDE Port (30004) because I can able to get the status back while the robot is running on 30004?