Home Programming

Discussion

Left ArrowBack to discussions page
jensssjensss Posts: 23 Apprentice
dear
I would like to control my UR5 with a python program. At the moment I'm trying it out with the ursim.  This is part of my bachelor's thesis. And since I can't do an internship right now, I want to realize this through the simulation. On pc 1 I make the program and send it to pc 2.
I can connect to the simulation through a socket connection. When I forward my python program, I don't get any error on my python program. I do get feedback. But the robot on my simulation does not move.
Do you know how this happened? Do I need to program something on my cobot to listen to my pc 1?
Attached you find my program and the feedback I get.

Thank you in advance for your time & answer.

yours sincerely

Comments

  • bcastetsbcastets Vacuum Beta tester Posts: 595 Expert
    edited April 2020
    Did you had a look at UR client interface documentation ?

    https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/overview-of-client-interfaces/

    Controlling UR via client interface is frequently used,

    UR also have a ROS package to control the robot. That may be interesting for you.
    http://wiki.ros.org/action/show/universal_robots?action=show&redirect=universal_robot
  • jensssjensss Posts: 23 Apprentice
    dear

    thank you for your reaction. 
    in this document there's port 30002 as a secondary interface, right?
    I've written a program where I set a digital output to True or false. And this succeeds, on my simulation I see these switching on and off. So there's comunnication?
    I can't just move the robot to a point.
  • jelmsjelms Posts: 34 Handy
    With minor modification and python3, it worked with the UR3 simulator running on the same machine that I ran the python script. I'm guessing it had something to do with if the position is within reach of the robot. I'd recommend looking at the log tab in the simulator to see if it the movej was executed.

    Also when you get to sending programs textmsg is useful in debugging. With the simulator you can also open a terminal and look at ~/ursim-current/URControl.log and ~/ursim-current/log_history.txt (the log_history.txt contains the messages from the log tab although messaged aren't always flushed to log_history, you can force it by using the clear button on the log tab).

    # Echo-clientprogramma<div>import socket</div><div>import time</div><div><br></div><div>host = "192.168.56.104" # De externe host</div><div>port = 30002 # Dezelfde poort als gebruikt door de server</div><div>print ('Startprogramma')</div><div>tel = 0</div><div><br></div><div>data = bytes("movej(p[-0.1, -0.2, 0.1, 0, 0, 3.14], a=1.3, v=1.9)" + "\n", 'utf-8')</div><div><br></div><div>while (tel < 1):</div><div>&nbsp; &nbsp; s = socket.socket(socket. AF_INET, socket. SOCK_STREAM)</div><div>&nbsp; &nbsp; s.connect((host, port))</div><div><br></div><div>&nbsp; &nbsp; time.sleep(0.5)</div><div>&nbsp; &nbsp; s.send(data)</div><div>&nbsp; &nbsp; time.sleep(5)</div><div>&nbsp; &nbsp; tel = tel+1</div><div><br></div><div>&nbsp; &nbsp; time.sleep(1)</div><div>&nbsp; &nbsp; data = s.recv(1024)</div><div>&nbsp; &nbsp; s.close()</div><div>&nbsp; &nbsp; print ("Received", repr(data))</div><div><br></div><div>print ("Status data received from robot")</div>


  • jelmsjelms Posts: 34 Handy
    With minor changes, the code below worked for me with python3 on the same machine that I was running UR3 simulator 3.5

    I'd look in the log tab to make sure the movej (or program) executed. When you start with programs, I'd use the textmsg() function to add custom log messages to the log tab.

    With the simulator you can also look at two log files ~/ursim-current/URControl.txt and ~/ursim-current/log_history.txt (log_history.txt is the same content as the log tab, although it's not alway flushed to. You can force a flush with the clear button on the log tab).

    <p># Echo-clientprogramma</p><p>import socket</p><p>import time</p><p><br></p><p>host = "192.168.56.104" # De externe host</p><p>port = 30002 # Dezelfde poort als gebruikt door de server</p><p>print ('Startprogramma')</p><p>tel = 0</p><p><br></p><p>data = bytes("movej(p[-0.1, -0.1, 0.1, 0, 0, 3.14], a=1.3, v=1.9)" + "\n", 'utf-8')</p><p><br></p><p>while (tel < 1):</p><p>&nbsp; &nbsp; s = socket.socket(socket. AF_INET, socket. SOCK_STREAM)</p><p>&nbsp; &nbsp; s.connect((host, port))</p><p><br></p><p>&nbsp; &nbsp; time.sleep(0.5)</p><p>&nbsp; &nbsp; s.send(data)</p><p>&nbsp; &nbsp; time.sleep(5)</p><p>&nbsp; &nbsp; tel = tel+1</p><p><br></p><p>&nbsp; &nbsp; time.sleep(1)</p><p>&nbsp; &nbsp; data = s.recv(1024)</p><p>&nbsp; &nbsp; s.close()</p><p>&nbsp; &nbsp; print ("Received", repr(data))</p><p><br></p><p>print ("Status data received from robot")</p><div></div>

  • jelmsjelms Posts: 34 Handy
    With a minor tweak I was able to get it to work. Not sure what the original error was. I used 3.6 ursim

    Debugging tips: With the UR simulator there are two useful log files:
    1. ~/ursim-current/URControl.log
    2. ~/ursim-current/log_history.txt

    The first one show lower level errors. The second is the same as on the log tab of the UI. But the\
     logs aren't flushed quickly. You can force a flush to the log_history.txt with the clear button o\
    n the log tab. This is counter-intuitive I know.

    Example error:

    tail -f ~/ursim-current/URControl.log

    <div>00:05:03:032 ERROR&nbsp; &nbsp;- RuntimeException: Syntax error on line 1: movej (P[-0.12011338870414279, -0.03284345685543577, 0.8116334436503265, -0.0012210094623466288, 3.1162765278382936, 0.93889180615015442], a=1.3962634015954636, v=1.9471975511965976)</div><div>00:05:03:032 ERROR&nbsp; &nbsp;- TCPReceiver::parseLine: Parse Error: movej (P[-0.12011338870414279, -0.03284345685543577, 0.8116334436503265, -0.0012210094623466288, 3.1162765278382936, 0.93889180615015442], a=1.3962634015954636, v=1.9471975511965976)</div><div><br></div><div>00:05:08:536 ERROR&nbsp; &nbsp;- TCPReceiver closed (exception caught): ServerSocket: Socket::recv() failed.</div><div>00:05:08:624 ERROR&nbsp; &nbsp;- MultiTCPSender send: ServerSocket: Socket::sendall() failed.</div><div>00:05:24:584 INFO&nbsp; &nbsp; - Starting program: movej</div><div>00:05:24:592 INFO&nbsp; &nbsp; - Runtime state change: from PROGRAM_STATE_STOPPED to PROGRAM_STATE_RUNNING</div><div>00:05:24:600 ERROR&nbsp; &nbsp;- Runtime error (1:1): The robot cannot reach the requested pose. Script function getInverse is unable to find an inverse kinematics solution.</div><div>00:05:24:608 INFO&nbsp; &nbsp; - Runtime state change: from PROGRAM_STATE_RUNNING to PROGRAM_STATE_STOPPED</div><div>00:05:30:136 ERROR&nbsp; &nbsp;- TCPReceiver closed (exception caught): ServerSocket: Socket::recv() failed.</div><div>00:05:30:216 ERROR&nbsp; &nbsp;- MultiTCPSender send: ServerSocket: Socket::sendall() failed.</div>

  • jelmsjelms Posts: 34 Handy
    The formatting of that was terrible, see attached
  • jensssjensss Posts: 23 Apprentice
    how can I force that?
  • jelmsjelms Posts: 34 Handy
    With minor changes, the code below worked for me with python3 on the same machine that I was running UR3 simulator 3.5

    I'd look in the log tab to make sure the movej (or program) executed. When you start with programs, I'd use the textmsg() function to add custom log messages to the log tab.

    With the simulator you can also look at two log files ~/ursim-current/URControl.txt and ~/ursim-current/log_history.txt (log_history.txt is the same content as the log tab, although it's not alway flushed to. You can force a flush with the clear button on the log tab).

    # Echo-clientprogramma

    import socket

    import time


    host = "192.168.56.104" # De externe host

    port = 30002 # Dezelfde poort als gebruikt door de server

    print ('Startprogramma')

    tel = 0


    data = bytes("movej(p[-0.1, -0.1, 0.1, 0, 0, 3.14], a=1.3, v=1.9)" + "\n", 'utf-8')


    while (tel < 1):

        s = socket.socket(socket. AF_INET, socket. SOCK_STREAM)

        s.connect((host, port))


        time.sleep(0.5)

        s.send(data)

        time.sleep(5)

        tel = tel+1


        time.sleep(1)

        data = s.recv(1024)

        s.close()

        print ("Received", repr(data))


    print ("Status data received from robot")


  • jelmsjelms Posts: 34 Handy
    With minor changes, the code below worked for me with python3 on the same machine that I was running UR3 simulator 3.5

    I'd look in the log tab to make sure the movej (or program) executed. When you start with programs, I'd use the textmsg() function to add custom log messages to the log tab.

    With the simulator you can also look at two log files ~/ursim-current/URControl.txt and ~/ursim-current/log_history.txt (log_history.txt is the same content as the log tab, although it's not alway flushed to. You can force a flush with the clear button on the log tab).

    # Echo-clientprogramma

    import socket

    import time


    host = "192.168.56.104" # De externe host

    port = 30002 # Dezelfde poort als gebruikt door de server

    print ('Startprogramma')

    tel = 0


    data = bytes("movej(p[-0.1, -0.1, 0.1, 0, 0, 3.14], a=1.3, v=1.9)" + "\n", 'utf-8')


    while (tel < 1):

        s = socket.socket(socket. AF_INET, socket. SOCK_STREAM)

        s.connect((host, port))


        time.sleep(0.5)

        s.send(data)

        time.sleep(5)

        tel = tel+1


        time.sleep(1)

        data = s.recv(1024)

        s.close()

        print ("Received", repr(data))


    print ("Status data received from robot")


  • jelmsjelms Posts: 34 Handy
    With minor changes, the code below worked for me with python3 on the same machine that I was running UR3 simulator 3.5

    I'd look in the log tab to make sure the movej (or program) executed. When you start with programs, I'd use the textmsg() function to add custom log messages to the log tab.

    With the simulator you can also look at two log files ~/ursim-current/URControl.txt and ~/ursim-current/log_history.txt (log_history.txt is the same content as the log tab, although it's not alway flushed to. You can force a flush with the clear button on the log tab).

    # Echo-clientprogramma

    import socket

    import time


    host = "192.168.56.104" # De externe host

    port = 30002 # Dezelfde poort als gebruikt door de server

    print ('Startprogramma')

    tel = 0


    data = bytes("movej(p[-0.1, -0.1, 0.1, 0, 0, 3.14], a=1.3, v=1.9)" + "\n", 'utf-8')


    while (tel < 1):

        s = socket.socket(socket. AF_INET, socket. SOCK_STREAM)

        s.connect((host, port))


        time.sleep(0.5)

        s.send(data)

        time.sleep(5)

        tel = tel+1


        time.sleep(1)

        data = s.recv(1024)

        s.close()

        print ("Received", repr(data))


    print ("Status data received from robot")


Sign In or Register to comment.
Left ArrowBack to discussions page