Send UR Script commands via sockets in Python

Hi all,

I want to send UR Script commands via sockets using Python to control my VG10 gripper tool remotely.
My code is shown in the next picture:

This script does nothing in the robot until the moveJ command, which is well executed. But I would like to send the vg10_grip() and vg10_release() commands with some parameters. I have proved these script commands in teachpendant to check if the robot can perform them. For that purpose, I have made the following robot program with vg10_grip() and vg10_release() commands, and when executing, the robot executes the program with no problem.

I’m not sure if it is possible to send these script commands for controlling the tool via sockets. But I need to do something similar, because controlling the tool using digital outputs doesn’t allow me to specify the vacuum level to achieve.

If any of you has any ideas, I would be so grateful.

Thank you in advance.

Hi Maria,

The problem is that the UR does not ‘know’ the commands from the tool.
When you use these commands in a program the UR already loads the libraries for the connected tools and therefore knows how to translate the vg10 command to more direct code.

I myself find it easier to use scripts and send these over to the UR. You could extract the script from the program you created from the UR and send that one over a socket. If you have the script you can use this sample code to test the full movements.

f = open(FILE_PATH, "rb")
l = f.read(1024)

while (l):
    tcp_socket.send(l)
    l = f.read(1024)

Use this instead of a tcp_command and tcp_socket.send.

Good luck!