1. Home
  2. Knowledge Base
  3. Testing UR Client-Server and script commands via TCP connection

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

This example shows how to test the Client-Server program showed on the forum with Sockettest program.

The program is loaded into the UR. In this case the Universal-Robots is configured with IP address 192.168.0.9.

See program description at the client server example. Link to UR Client-Server example.

However in this test the timer Wait after sending the trigger string has been increased to 5 seconds because the reply data will be manual entered  – so in order to provide sufficient time for human to type in reply data the timer is set as 5 seconds or higher. If it is a host or PC with an automatic reply routine then this timer can be much lower as in the original example.

universal-robots-testing-client-server-tcp-connection-2

On a PC which is configured with IP address 192.168.0.100 the Sockettest program is started and configured.

Notice the Tab “Server” is selected and the IP address given is the IP address of the PC because it acts as a server in this case and the robot is the client – and the port is selected as 30000 because that´s the port used in the robot program, but it could be another unused port number as long it is the same on both sides.

universal-robots-testing-client-server-tcp-connection-1

The program on the robot is started.

universal-robots-testing-client-server-tcp-connection-3

And the Server detect an incoming client. Notice the string “asking_for_data” which the robot has send to the server.

Data is entered in the Message window – in this case (200,50,90) which is the corresponding X, Y, Rz data expected by the robot program. This kind of data is very similar as in a vision where the camera will reply with the X, Y and Theta Angle coordinates for an object to detect.

universal-robots-testing-client-server-tcp-connection-5

After the data is entered the Send is pressed so that data is send over the TCP connection to the robot.

universal-robots-testing-client-server-tcp-connection-6

In the “Variables” tab on the robot the data received can be observed – notice the variable var_2 which is the receiving variable has the value [3.0, 200.0, 50.0, 90.0] i.e. 4 elements where the first element is 3.0 meaning that 3 sets of data was received – namely 200.0 and 50.0 and 90.0.

And the robot moves accordingly 200 mm i X direction and 50 mm in Y direction and turn the tool head 90 degrees.

And then the program loops back to request for new data.

 

Note:
If the Server PC does not respond to the request for opening the port – then it might be because the server is out of synchronization with open and close of port and restart of the server might be necessary.

If the var_2 shows [0.0, NaN, NaN, NaN] it means no valid data was received (NaN = Not a Number).

universal-robots-testing-client-server-tcp-connection-7

 


Contribute moderator




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?

12 comments

  1. Hi,

    Yes I know this :) I changed a couple of things to make the code work. As I said, the outputs (from the robot) are read without any problem! So I really think it’s not a Python 2 vs 3 issue but more an error on my end..

    Is it possible to contact Alexandro Guajardo (the other person who had the same problem) ? Or can I speak with someone at UR about this? Maybe they have a beta version of RTDE for Python 3.

    Thank you :)

  2. Hi,

    Yes I know that. I am able to sync the outputs of the robot controller without any problem. Right now, only the inputs cause problem. I don’t think it’s a Python Version issue..

    Is it possible to communicate with Alexandro Guajardo or with directly with UR to see if they saw this error in the past and only give me a hint?

    Thank you

    Michael

  3. I got this raised error from the serialize.py code:

    –> ValueError(‘An input parameter is already in use.’)

    If I trace back to the source, I think this line (see bellow) in the rtde.py causes the problem:

    Function def __recv(self, command):

    ——> more = self.__sock.recv(4096) <——–

    The variable ''more'', changed only at this time, contains ''IN_USE'' when I debug this line.. I really think the problem is in the robot controller or I don't initialize something correctly..

    I'm blocked right now because of this..

    Thank you for your help :)

      1. Hi Michael

        The Python examples shown in the articles are using Python 2.7. There is a substantial difference in Python 2.7 and Python 3.x and they are not directly compatible.

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

        Also check out the CB3 forum



    1. Hi Michael

      The Python examples shown in the articles are using Python 2.7. There is a substantial difference in Python 2.7 and Python 3.x and they are not directly compatible.

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

      Also check out the CB3 forum



  4. Hi,

    On the UR i get the error :
    nameerror: name ‘get_actual_tcp_pose’ is not defined
    This is also for ‘get_actual_loint_positions’ and ‘pose_positions’
    Can you help me?

    1. Hi Steven

      Thanks for the question.

      Can you show the code – in order to see if it is a spelling or the way the command is used.

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

      Also check out the CB3 forum



  5. Hi,

    I am currently trying to implement a Python based program utilizing the RTDE module provided by Universal Robots. I am receiving an error from the server on the controller box stating that the input parameters are already in use. I have narrowed it down to a response in String format saying “IN_USE” for any input register I try to initialize. All the output registers that I have initialized till now have worked without a problem. Why does it say that it is in use when I have never initialized those input registers and there is no program running on the robot.

    PS: The link to the RTDE client and its guide: https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/real-time-data-exchange-rtde-guide-22229/

    1. Hi Alexandro

      Thanks for the question.

      Can it be that it is trying to write to an input ?

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



      1. Hi,

        I got the same problem here! All my ouputs are working fine but I can’t even setup the inputs. ”IN_USE” is all I got when I try different inputs..

        Any solution 😀 ?

        Thanks

        1. Hi Michael

          Thanks for the question.

          In which screen do you see the “IN_USE” messages ?

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

          Also check out the CB3 forum



Leave a Reply to zacobria Cancel reply

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