I have created a URScript file via Python but I am having a hard time figuring out how to send the entire script file through the Primary Interface (Port: 30001). I have successfully used the Dashboard Interface and custom Ports in the past but can’t seem to figure out the format in which to send a .script file.
Here is the Python code for sending the file.
def RobotInterface(command: str):
# initialize variables
robotIP = "172.28.XXX.XXX"
PORT = 30001
# create socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((robotIP, PORT)) # connect to UR port 30001
s.send(command.encode()) # encode data and send through socket
s.close() # close the socket
print("Dashboard Command Complete")
Where the input to this command is:
with open(scriptFile) as f:
lines = f.read()
URF.RobotInterface(lines)
When this code is ran, I receive the “Dashboard Command Complete” statement which means that the socket was opened and something was sent (correct?). However, the robot doesn’t move or throw an error, it does nothing.
I have manually loaded the scriptFile to my UR and ran it from PolyScope and it performs as expected. I think the issue is how I am trying to send the file from Python. How do you send a .script file? Does it need to be condensed into one single variable consisting of \n
markers? Is it possible to send the whole file in one command?
Structure of the scriptFile :
def moves():
movej(get_inverse_kin(...))
movej(get_inverse_kin(...))
movej(get_inverse_kin(...))
movej(get_inverse_kin(...))
end