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.
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.
The program on the robot is started.
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.
After the data is entered the Send is pressed so that data is send over the TCP connection to the robot.
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.
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).
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.
By Zacobria Lars Skovsgaard
Accredited 2015-2018 Universal Robots support Centre and Forum.