Discussion

Left ArrowBack to discussions page
MarvinWMarvinW Posts: 3 Apprentice
Hi Everyone,

since the last time it was so helpfull (big thanks to matthewd92!) to ask here a question a have another one.

We have the UR10 and in our applikation the robot have to execute different tasks depending on which state the machine is he has to serve. So, there is a Client which tests something the Robot has to put in. There is a Server connecting this Client to the Robot, sending for the Moment simple commands via the socket Connection. Now we maybe have a bunch of scripts of possible movements of the Robot an there is a objectrecognition function also with a camera. The big question is how to Control everything depending on the different states of the Client. An idea was to have a scriptbib and depending on the state we just send the Robot a whole Script but we did not find out how to do this via the sockets, is this even possible?

Again, thanks a lot and have a good day!

Comments

  • louis_bergeronlouis_bergeron Posts: 87Beta Tester Beetle, Wrist Camera URCap 1.3.0 Handy
    @MarvinW

    You can send a whole script to the UR with a socket connection to the client at the port 30001 - 30002 - 30003. Your script file must start with a def() end finish with an end to work correctly.  This is an example I have done last year in Python to send a file and execute it:

    # Echo client program
    import socket
    
    HOST = "10.20.1.102" # The UR IP address
    PORT = 30003 # UR secondary client
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    
    f = open ("setzero.script", "rb")  #Robotiq FT sensor
    
    l = f.read(1024)
    while (l):
        s.send(l)
        l = f.read(1024)
    s.close()
    

    The script file setzero.script is:

    def rq_set_zero():
      	if(socket_open("127.0.0.1",63350,"acc")): 
      		socket_send_string("SET ZRO","acc")
      		sleep(0.1)
      		socket_close("acc")
      	end
    end
    

    You can find information about this connection on the UR website: 

    https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/remote-control-via-tcpip-16496/



    Louis Bergeron
    Integration Coach
    robotiq.com
    [email protected]
  • MarvinWMarvinW Posts: 3 Apprentice
    Thank you very much for your quick Response!
    I tried it exactly the way you wrote it here but i didn't manage it. 
    I took the python Code for the Client as it is and then modified the script Code, you can see it below. 
    In this line you give your port as a fix integere but from where do you know it? It's something that does your OS for you i thougt. 
    if(socket_open("127.0.0.1",63350,"acc")): 
    
    The modified Code, with an additional line so that i can see if the Robot is moving (in URSim) and that i could see in the response the message with the multiple \xff ' s. 
    def rq_set_zero():
    if(socket_open("127.0.0.1",63350,"acc")):
    socket_send_string("SET ZRO","acc")
    sleep(0.1)
    movej(p[0.603, 0.729, -0.309, 3.539, -1.146, 0.186], a=1.200, v=0.50, r=0)
    sleep(2)
    socket_send_string("\xff\xff\xff\xff\xff\xff","acc")
    socket_close("acc")
    end
    end
    But neither i get the message back(a lot of Bytes but not the \xff's)( i print it in the while-loop) nor i can see the Robot moving. 
    I deleted the if condition to try if that would change the behavior but nothing happens. 
    Do you have any suggestions? Anything would help :) 
  • matthewd92matthewd92 Posts: 699Founding Pro, Tactile Sensor Beta Testers Handy
    edited November 15
    The one thing that I notice is you are sending robot commands to the FT Sensor.  The robot commands need to be sent to either port 30001, 30002 or 30003.  In the file that you are sending to the robot you are sending the set_zero command to the FT sensor and then trying to move which is perfectly fine.  Just change the port that you are sending the whole file to back to 30003.

    Or I may be misunderstanding what you are asking.  Do you have a FT sensor installed on the robot?  If not, the port is never opening and therefore you are not getting into the if statement.

    Try modifying the script you are sending to the following

    def rq_set_zero():
    if(socket_open("127.0.0.1",63350,"acc")):
    socket_send_string("SET ZRO","acc")
    sleep(0.1) socket_close("acc")
    end movej(p[0.603, 0.729, -0.309, 3.539, -1.146, 0.186], a=1.200, v=0.50, r=0) sleep(2) socket_send_string("\xff\xff\xff\xff\xff\xff","acc")
    end
Sign In or Register to comment.
Left ArrowBack to discussions page