1. Home
  2. Knowledge Base
  3. Testing TCP connection Host to UR

Testing UR Client-Server and script commands via TCP socket connection.

To test the TCP socket connection from a host (PC) to a Universal-Robots the program Sockettest can be used.

In this example the robot is connected to a router with a RJ-45 Ethernet cable – and the computer is connected to the same router via WiFi. Notice that the computer is not connected directly to the robot Ethernet port because that is a unliekly situation in an application.

The computer IP address configuration can be found on a Windows computer by running a DOS box  – which can be done by Run and “cmd”.

universal-robots-testing-client-server-script-commands-via-tcp-connection-ip-adr-2.jpg

In the DOS box the IP configuration can be found with “ipconfig”

universal-robots-testing-client-server-script-commands-via-tcp-connection-ip-adr-3.jpg
universal-robots-testing-client-server-script-commands-via-tcp-connection-ip-adr-4.jpg

In this example the computer has the IP address 192.168.0.100 – the Subnet setting is 255.255.255.0 and the default gateway is 192.168.0.1

So In this example the robot IP address is configured to 192.168.0.11 – subnet 255.255.255.0 and gateway and DNS is configured for the router address i.e. 192.168.0.1

universal-robots-testing-client-server-script-commands-via-tcp-connection-ip-adr-1.jpg

The host and robot needs each their own IP address and in the same subnet so they can communicate .

A good start is to see if it is possible to ping the robot from the host (computer).

universal-robots-testing-client-server-script-commands-via-tcp-connection-ip-adr-5.jpg

Here is a good reply from the robot.

Below shows the Sockettest connected to a robot with IP address 192.168.0.11. Notice that the PC where the Sockettest is running is the client and it connects to the robot at address 192.168.0.11 and port 30002.

See also this page for port description on the UR. Link to UR real time server.

universal-robots-testing-client-server-script-commands-via-tcp-connection-1a

Notice the data that is shown in the “Conversation with host” screen. It looks like random data, but it is Matlab data send out from the robot – so this is normal.

When the communication has been verified – Then a simple test can be performed by sending a script command that set an output high.

Below shows the I/O screen before sending a command.

universal-robots-testing-client-server-script-commands-via-tcp-connection-1

Then the command set_digital_out(1, True) is send to the robot via the TCP socket connection.

universal-robots-testing-client-server-script-commands-via-tcp-connection-2

Which sets the digital output high on the robot.

universal-robots-testing-client-server-script-commands-via-tcp-connection-3

To set the output low again the script command set_digital_out_(1, False) is send over the TCP socket connection.

universal-robots-testing-client-server-script-commands-via-tcp-connection-4

And the out number 1 go low again.

universal-robots-testing-client-server-script-commands-via-tcp-connection-1
Disclaimer: While the Zacobria Pte. Ltd. believes that information and guidance provided is correct, parties must rely upon their skill and judgement when making use of them. Zacobria Pte. Ltd. assumes no liability for loss or damage caused by error or omission, whether such an error or omission is the result of negligence or any other cause. Where reference is made to legislation it is not to be considered as legal advice. Any and all such liability is disclaimed.

If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.

Author:
By Zacobria Lars Skovsgaard
Accredited Universal Robots support Centre and Forum.

Also check out the CB3 forum



Was this article helpful?

10 comments

  1. Hello,
    I could need some help. I would like to use the rtde interface on port 30004. When I want to run the control loop example on my workstation, I get the following error:
    ‘Unable to negotiate protocol version.’
    I am using a UR10 with 3.3.4.310 and I am using the newest example code from the UR support page. The network is set up properly, as my workstation finds my robot. Do I have update the software of my robot to 3.4 to use the rtde?
    Does anyone have an idea, why I get this problem and how to fix it?

    Thanks.

    1. Hello Kai

      Thanks for your question.

      I have not worked with “rtde”, but maybe others on the forum has.

      Author:
      By Zacobria Lars Skovsgaard
      Accredited Universal Robots support Centre and Forum.

      Also check out the CB3 forum



  2. Hello, I did as the process with Sockettest, and I could receive data from the UR5 when connnected to port 30002.but there is no any change for the digital port. Also I tried it with the “popup”, and no dialog appeared on the polyscope too, why?

    1. Hello wayne

      Which commands did you send ?

      Author:
      By Zacobria Lars Skovsgaard
      Accredited Universal Robots support Centre and Forum.

      Also check out the CB3 forum



      1. Hello.Just the set_digital_out(1, True) and the popup. It seems that not any reply for me to use port 30001-30003 just by SocketTest and DashBorad is OK!

        1. Hello wayne

          So you mean the output change is OK when you use the SocketTest ?

          Author:
          By Zacobria Lars Skovsgaard
          Accredited Universal Robots support Centre and Forum.

          Also check out the CB3 forum



    1. Hi Sun Qiang

      Thanks for the question.

      There are some informations about using port 30004 at this link.

      https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/real-time-data-exchange-rtde-guide-22229/

      Author:
      By Zacobria Lars Skovsgaard
      Accredited Universal Robots support Centre and Forum.

      Also check out the CB3 forum



  3. A couple of questions — when communicating via Port 30002, how does the UR send return data? (for example, the value in “get_actual_tcp_pose()” Is it in this Matlab code?

    If so, how do we read this Matlab code? Do we need to program a socket connection in Matlab?

    Thanks.

    1. Hi Paul

      On port 30002 the robot does not respond to “get_actual_tcp_pose()” because the commands send to port 30002 is oneway commands i.e. the commands can write things to the robot like outputs and positions, but cannot read back.

      See also this explanation

      http://www.zacobria.com/universal-robots-knowledge-base-tech-support-forum-hints-tips/knowledge-base/script-from-host-to-robot-via-socket-connection/

      Yes the data flowing out from port 30002 is matlab data and these data flows even if no commands are send to the robot on port 30002.

      To get the data back for “get_actual_tcp_pose()” a Client-Server scenario can be used an similar example is at this link

      http://www.zacobria.com/universal-robots-zacobria-forum-hints-tips-how-to/script-client-server-example/

      Or some data can also be read from the MODBUS registers.

      http://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/modbus-server-16377/

      I have not used Matlab, but here are more links about the Matlab.

      http://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/remote-control-via-tcpip-16496/

      http://www.mathworks.com/matlabcentral/fileexchange/50655-ur5-control-using-matlab

      Author:
      By Zacobria Lars Skovsgaard
      Accredited Universal Robots support Centre and Forum.

      Also check out the CB3 forum

Leave a Reply

Your email address will not be published. Required fields are marked *