Physical robot and digital robot realize synchronous motion(TCP/IP)

  1. Currently, communication between two different robots in VC can be realized. And achieved synchronization. The implementation code is as follows:




  1. The SOCK _Type in the code is SOCK_DGRAM. The way to establish a connection is that the server listens but does not reply. The client only sends the data, so this is the UDP transmission form. However, our robot does not support UDP only supports TCP/IP, so UDP cannot be applied to the communication between physical robots and virtual robots we now have.
  2. We tried TCP/IP non-blocking and blocking transmission modes in VC. Since VC is based on single-threaded transport, we use non-blocking transport. However, after the program is written, the situation is not good during the operation of the VC. Code show as below:

TCP-ServerAs long as it runs, it will be stuck. How can I solve it?

Have you contacted support?


I had similar problems of getting everything stuck when implementing socket connections between VC and external clients. In my case the code got stuck on recv() if the socket receive buffer didn’t have anything to read. The solution was to use to first check if the buffer has got something to read and then to use recv() only if there’s something.

Found some old code that might or might not do the trick in VC4.1. Self.connections is a list of currently established sockets.

while len(,[],[],0)[0]) == 0: # nothing to read
reply = self.conn.recv(1024)