Home Programming


Left ArrowBack to discussions page
PrasannaPrasanna Posts: 56 Apprentice
Hi @matthewd92
Pls find the attachment. am communicating my PC to UR3e. 
PC will send co-ordinates to robot. Gripper also communicating in socket with UR3e.
1. But do i need to open and close the socket everytime. because it takes too much of time.
2. Can i add socket open command in thread so that it will be open all the time.
3. check the pictures. i want to run "Glue dispense " program for 5 times. how should i do without using socket open and close? or is there any method for socket speed optimization.

thanks in advance

Best Answer

  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,266 Handy
    Answer ✓
    First thing I notice is you have some really long waits in your socket communications, have you tried taking those waits out?  In my experience opening a socket is pretty fast. You have 2.5 seconds of wait time between the send, the receive and using the coordinates. We generally have at most 100 ms delay between sending multiple writes to the server but if I’m sending a request and waiting for a response those lines are written back to back. 

    That’s where I would start to look at reducing times. You could then look to open the socket just once for the program and use that open socket, we do that as well but it needs to be a connection that is long lived so that the server doesn’t close the connection if data is not received for a period of time. I do not recommend to just keep opening sockets in a thread as you would be opening a lot of unneeded sockets and could cause performance issues on the robot or the server. Unfortunately UR does not provide any methods for determining if the socket is open or closed, so you could write your own where you make a request to the server and so long as it does not time out you know the server connection remains open, on a timeout event you could reopen the socket. 

    In my experience though its not a huge detriment unless I’m talking to the server non-stop. Then UR has a better tool for that called xmlrpc but it requires you to have an xmlrpc server not just a simple tcp socket. Once you understand how to write the server, and there are libraries to do that depending on what language you are using, they are very easy to use and very performant. We are sending multiple commands within a single sync cycle of the robot. 


  • PrasannaPrasanna Posts: 56 Apprentice
    Thanks @matthewd92
    1. Am using C# program. 
    2. am opening and closing the socket because once i send command to the server, the socket gets disconnected automatically . I do not know why. Same happens in the SOCKETPLUS, a 3rd party s/w.
    So i thought its a nature of a socket communication 
    3. Wait time is too long.... I tried by reducing the wait time but some time i didn't receive any response from server.... So found no options.

    Kindly help on this.... I need to optimize my program and cycle time

    I have no idea of xmlrpc, i will find it out...if you have any sample codes or link... Kindly send me
Sign In or Register to comment.
Left ArrowBack to discussions page