Launching the program

Hello

Currently i want to run a script python on the universal robot via tcp/ip but i run into a problem. Below the code:

import socket
import time
adresse_ip = “169.254.225.36”
port = 29999

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
client_socket.connect((adresse_ip, port))
client_socket.send((“power on” + “\n”).encode())
time.sleep(10)
client_socket.send((“brake release” + “\n”).encode())
time.sleep(10)
client_socket.send((“load alpha.urp” + “\n”).encode())
time.sleep(10)
client_socket.send((“play” +“\n”).encode())
time.sleep(20)
client_socket.send((“power off” + “\n”).encode())
time.sleep(10)
except Exception as e:
print(e)

client_socket.close()

All command seems to be exectued well, apart for the play command that permit me to run the program loaded previously.

I wonder if anyone have any idea what’is the problem.

You should probably add some way of receiving the response after each command that was sent to check if there are any errors from the robot.

If I am not mistaken you can do this by simply adding

rcvd = client_socket.recv(4096)
print(rcvd)

after the sleep statement after each command was sent.

What is the response you get from the robot when trying to execute the play command?

Hi

Here the program that i modifed after your advice:
import socket
import time
adresse_ip = “169.254.225.36”
port = 29999

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
client_socket.connect((adresse_ip, port))
client_socket.send((“power on” + “\n”).encode())
rcvd = client_socket.recv(4096)
print(rcvd)
time.sleep(10)
print(“1”)
client_socket.send((“brake release” + “\n”).encode())
rcvd = client_socket.recv(4096)
print(rcvd)
time.sleep(10)
print(“2”)
client_socket.send((“load alpha.urp” + “\n”).encode())
rcvd = client_socket.recv(4096)
print(rcvd)
time.sleep(10)
print(“3”)
client_socket.send((“play” +“\n”).encode())
rcvd = client_socket.recv(4096)
print(rcvd)
time.sleep(20)
client_socket.send((“power off” + “\n”).encode())
except Exception as e:
print(e)

The output of the program:

b’Connected: Universal Robots Dashboard Server\n’
1
b’Powering on\n’
2
b’Brake releasing\n’
3
b’Loading program: /programs/alpha.urp, /programs/default.installation\n’

Essentially just the play instruction doesn’t work even though the others instructions work.

Weird…
There is no response or error after the play command?

This exact code works on my robot without issue.

What Robot and Polyscope Version are you using?

I believe your program takes a while to load, how large is it?
It may be that the robot has not finished loading when the play command is sent.

Try to increase the time between loading and playing to see if it makes a difference.

The robot is an UR5e, the polyscope us the version 74.13.220

maybe you should wait to send load and play until your robot is fully startet by waiting for the robotMode to go to “RUNNING” or “IDLE”

Then you could ask which program is loaded befor trying to play it, so you can be sure, that the loading is finished