User Tools

Site Tools


vrep:socket-com-with-robot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
vrep:socket-com-with-robot [2020/04/16 19:53]
admin
vrep:socket-com-with-robot [2020/04/16 20:00]
admin
Line 120: Line 120:
 </​code>​ </​code>​
  
-The socket transfers binary data, so we need to pack the data before sending them and unpack them at the reception. For Lua we use the [[http://​webserver2.tecgraf.puc-rio.br/​~lhf/​ftp/​lua/​|lpack ​libary]. You can either download the code and recompile **the pack.so** shared library or get it  [[https://​www.ensta-bretagne.fr/​zerr/​filerepo/​vrep/​pack.so|already compiled here]] if you work on x86_64 linux computer. The file **pack.so** should be added in the main V-REP directory.+The socket transfers binary data, so we need to pack the data before sending them and unpack them at the reception. For Lua we use the [[http://​webserver2.tecgraf.puc-rio.br/​~lhf/​ftp/​lua/​|lpack ​library]]. You can either download the code and recompile **the pack.so** shared library or get it  [[https://​www.ensta-bretagne.fr/​zerr/​filerepo/​vrep/​pack.so|already compiled here]] if you work on x86_64 linux computer. The file **pack.so** should be added in the main V-REP directory. ​ 
 + 
 +//Todo : provide a .dll for windows//
  
 The socket is between processes on the same computer so the IP address is **localhost** or **127.0.0.1**. The communication port is set to **33211**. The port number is arbitrary, if this port is already used, we will get an error message. To get a list of used port, you can use **lsof**. Here we print only the ports used by V-REP: ​ The socket is between processes on the same computer so the IP address is **localhost** or **127.0.0.1**. The communication port is set to **33211**. The port number is arbitrary, if this port is already used, we will get an error message. To get a list of used port, you can use **lsof**. Here we print only the ports used by V-REP: ​
Line 190: Line 192:
 def interrupt_handler(signal,​ frame): def interrupt_handler(signal,​ frame):
     print ('You pressed CTRL-C, end of communication with V-REP robot'​)     print ('You pressed CTRL-C, end of communication with V-REP robot'​)
 +    time.sleep(0.5)
     try:     try:
         sock.close()         sock.close()
Line 199: Line 202:
 signal.signal(signal.SIGINT,​ interrupt_handler) signal.signal(signal.SIGINT,​ interrupt_handler)
  
-# client ​connection ​every 50 ms+# client ​connects to server ​every 50 ms
 loop_duration = 0.050 loop_duration = 0.050
 while True: while True:
Line 241: Line 244:
                ​(tsock,​vrx[2],​vrx[3]*180.0/​math.pi,​vrx[4]*180.0/​math.pi))                ​(tsock,​vrx[2],​vrx[3]*180.0/​math.pi,​vrx[4]*180.0/​math.pi))
     else:     else:
-        print ("​tsock",​tsoc,"ms, bad data !!")+        print ("​tsock",​tsock,"ms, bad data !!")
  
     tsleep = loop_duration - (time.time()-t0)     tsleep = loop_duration - (time.time()-t0)
     if tsleep>​0:​     if tsleep>​0:​
-        time.sleep (tsleep) +        time.sleep (tsleep)  ​
-  +
 </​code>​ </​code>​
  
 Go to [[vrep:​socket-com-with-robot|top]] Go to [[vrep:​socket-com-with-robot|top]]
vrep/socket-com-with-robot.txt · Last modified: 2020/06/09 16:39 by admin