Universal Robots Forum

Cannot send socket commands to UR 10e

Hello there,

We just got a UR 10e to our lab and we were testing if we can send commands to it through socket. If I use port 29999 I can connect to the Dashboard Server and receive whatever data I want (i.e. robotmode, safetymode etc…). However, when switching to port 30002 to send commands such as set_digital_out() I don’t see any change happening on the panel.

I am using the following code to achieve this

import socket
import time

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('192.168.2.66', 30002))

def sendCommand(cmd):
    cmd = 'def program():\n ' + cmd + '\nend\n'
    print(cmd)
    s.send(cmd)

while (True):
    sendCommand('set_digital_out(0, False)')
    time.sleep(1)
    sendCommand('set_digital_out(0, True)')
    time.sleep(1)

The terminal only continuously prints the command I’m sending since I’m asking it too but does not show any errors. Is there something I am doing wrong from my part?

To comply with ISO 10218-1, the robots in e-series comes with mutually exclusive local/remote control modes. So one idea can be to check that your robot is in remote control mode. See maunal 21.3.3 on Remote control accessed from top right hamburger meny and then settings.

2 Likes

A simple test to check if the problem is the connection, run netstat -an | grep 30002 on the robot or your host which runs the python, if it is established.
I tried your script on the URSim for UR10e, changing the IP to 127.0.0.1, and it worked fine. But also the sim seems to ignore the remote/local settings, so for checking that it might not be much of help.

Thank you! Did not know you had to enable this option to be able to control the robot .