Discussion

Left ArrowBack to discussions page
VT_340VT_340 Posts: 21 Apprentice
edited June 15 in Programming
Hi!

I want to make the UR5 make draw random lines, arcs and circles on a piece of paper. My approach for that so far was to generate the geometry in Processing (Java for creatives..) and send points via TCP as moveP commands. The problem is that for example I was not able to make a smooth motion, even with a small blend radius and high "solution" up to 50 points per arc. Any idea how this problem is solved?  Would also use ROS or other solutions asI am in a early project-phase and just want to collect potential ways how to do it.

Thanks in advance.

Comments

  • BeachChEBeachChE Posts: 17Founding Pro Handy
    Look at using a MoveP command.
  • matthewd92matthewd92 Posts: 521Founding Pro, Tactile Sensor Beta Testers Handy
    If you are sending the points from off robot use a servoj command, it is designed to have a point sent every 8ms so you will need to calculate at a high resolution the motion but you can make very smooth moves this way. 
  • VT_340VT_340 Posts: 21 Apprentice
    edited May 30
    Hi! Thanks for your reply. According to the documentation servoJ is not working with the inverskinematic as you should provide joint positions? I now have another approach in mind. Maybe I do not need to send data quiet often but send a whole program that consist of several points and making the arcs with a predefined blend radius? Can I send a whole programm  via TCP and then just start it? This doesn't allow me to draw complex forms but maybe this is not a must.


  • matthewd92matthewd92 Posts: 521Founding Pro, Tactile Sensor Beta Testers Handy
    I have never tried to send a whole program but there is a way to do it.  You would send the program to one of the client interface ports and I believe that it then starts running as soon as it's received, if not you could send the play command to the dashboard server after you sent the program.

    You could also place the get_inverse_kin() function inside the servoj function to use TCP coordinates and calculate the required joint positions.  I have done that before successfully.
  • VT_340VT_340 Posts: 21 Apprentice
    Are there any more informations about how to load a SCRIPT program via TCP and how to play it? 
  • matthewd92matthewd92 Posts: 521Founding Pro, Tactile Sensor Beta Testers Handy
    I know how to load a program, that is rather straightforward via the dashboard server but I think you mean you want to transmit the program and then have it run if I am following you correctly. Your best resource for that would be the UR Support website.  Have you looked out there yet?
  • VT_340VT_340 Posts: 21 Apprentice
    edited May 30
    Hi Matthew

    Well documentation is a bit poor sometimes but I figured it out myself. 

    You can just send s.th like this via TCP:

    def primaryProgram():
      while (True):
        movep(p[-0.20000000, -0.10000000, 0.40000001, -3.14159274, 0.00000000, 0.00000000], a=0.10000000, v=0.30000001)
        movep(p[-0.20000000, -0.10000000, 0.10000001, -3.14159274, 0.00000000, 0.00000000], a=0.10000000, v=0.30000001)
      end
    end

    This must be sent as one string while the spaces for the blocks must be included. Once code is sent to port 30002 the program starts automatically. Don't forget to add a line feed (10) at the end of your string, otherwise it won't work properly.

    Thanks and greetings from germany.
  • VT_340VT_340 Posts: 21 Apprentice
    I have another question! Can somebody tell me whats a good point-to-point distance when calculating the  interpolation of a trajectory? I need to do some programming but cannot use the robot right now ( Holiday..)

    Thanks in advance!
  • VT_340VT_340 Posts: 21 Apprentice
    edited June 26

    Can you help me with the syntax a bit? I tried the following:

    servoj(get_inverse_kin(-0.028682, -0.467049, 0.05000001, -3.14159274, 0.00000000, 0.00000000), t = 0.05)

    This lines results in a a popup-error claiming this:

    "TypeError: get_inverse_kin() takes at most 4 arguments (6given)"

    Seems lik a bug or something, a pose consists of 6 floats .. no?

    Thanks in advance!


    VT

  • matthewd92matthewd92 Posts: 521Founding Pro, Tactile Sensor Beta Testers Handy
    edited June 26
    But a pose is in this format p[-0.028682, -0.467049, 0.05000001, -3.14159274, 0.00000000, 0.00000000]

    Change your line to read:

    servoj(get_inverse_kin(p [-0.028682, -0.467049, 0.0500, -3.14159, 0, 0], t=0.05)


    Let me know if you have any issues with that.
  • VT_340VT_340 Posts: 21 Apprentice
    edited June 26
    HA!  now the TCP  follows a line that I generated before in python. Thanks a lot.
  • matthewd92matthewd92 Posts: 521Founding Pro, Tactile Sensor Beta Testers Handy
    Anytime, glad it's working.  Post up a video when you get it all working, curious to see it in action
  • VT_340VT_340 Posts: 21 Apprentice
    Another question: How can I rotate for a example the last axis only to use it as a rotational-device? When I get it right I need to do some Euler-Angel maths to make the "Object" rotate around one axis only?


  • fLY9636fLY9636 Posts: 3 Apprentice
    Hi VT_340, I'm also experimenting on UR5 arm. I met the same problem as you, which turned out to be unable to move smoothly with commands like movec, movej and movel. I programmed on LabVIEW. I'm wondering how servoj managed to work in your project? I've tried this command but still no effect yet. Coz I saw you just finally made it, right?
  • VT_340VT_340 Posts: 21 Apprentice
    Hi! Yes I managed that you can see here:



    Do you need realtime change of your path? Or is it OK to once generate your trajectory and then just give the robot a go to perform a certain movement?
  • fLY9636fLY9636 Posts: 3 Apprentice
    Realtime control I think, and change the path immediately whenever I want.
  • VT_340VT_340 Posts: 21 Apprentice
    edited November 1
    Well OK as you may can imagine you want to do the more difficult stuff. I don't know how much you know about the UR5 already but don't hesitate to ask further questions. I used the ROS driver written by Thomas Timm Andersen. This transfers a program to the robot which then opens a TCP port for sending the six joint angle values with ~125hz. In my video I did some spline-curve-interpolation in python and send the coordinates to the robot as described. I changed the driver so that you can use the internal invers kinematic of the UR5. Why this complicated? Read his paper to understand it: http://orbit.dtu.dk/files/117833332/Universal_Robot_report.pdf

    You can use ROS to do this, or just use python or whatever to once send the driver-program to the robot and then send poses or joint values via TCP by your realtime application. (like I did) 


  • TomTom Posts: 3 Apprentice

    hi, Matthew,VT_340,
    I am trying to control ur5 running through a trajectory in windows. I want to use the script function:servoj(), but my data format is based on the tool space(a vector:X,Y,Z,RX,RY,RZ), so I need to translate the data to joint space. I found the ur5 script manual, and one of the functions that i can give is called get_inverse_kin(). if i have a c++ program running on an external pc, and i send this command to the ur5 to get the joint position, 
    then try to use the servoj to servo ur5 to the joint position. 

     but the robot had no response.Followed my script code:

    def trajPlan():
    cmd_servo_q=get_inverse_kin([0.55718 -0.04416 0.45048 -0.95300 1.49430 -0.60280])
    servoj([cmd_servo_q],t=2)
    end

    Could you help me out?

    Tom

  • VT_340VT_340 Posts: 21 Apprentice
    edited November 3
    Hi!
    This can be tricky, because you need to take care of the exact syntax. Look how my Python script looks like:

    cmd_str = "def socketdriverProg(): " + "\n"
    ...
    cmd_str += "    " + "if q[6] == 2.0:" + "\n"
    cmd_str += "     " + "servoj(get_inverse_kin(p[q[0],q[1],q[2],q[3],q[4],q[5]]), t=%f)" % (servojTime) + "\n" 
    cmd_str += "    " + "end" + "\n"

    ...

    In the end I send the program as one long string to the port.
    Take care of control character, space etc. when sending the script. Try first something very easy like switching an I/O or s.th to the that the communication in general works.
  • TomTom Posts: 3 Apprentice
    VT, thanks for your advice,I tried the following code:
    my_str="def trajPlan():\n ";
    my_str+= " servoj(get_inverse_kin(p[-0.028682, -0.467049, 0.0500, -3.14159, 0, 0], t = 5)\n";
    my_str+= "end\n";
    Then I send the program as one long string to the port (tried both 30002 and 30003 ), but the robot still had no response. Was something wrong?
  • VT_340VT_340 Posts: 21 Apprentice
    Hi!

    As I wrote you need to take care of the characters, including the whitespace character. URScript works like Python so whitespace character is an issue so thats why I included them in my string.
    Make your program easier for beginning just to see if the syntax is correct:

    my_str="def testPopUp():\n "; 
    my_str+="  "; 
    my_str+= "popup(\”Messages\”, title=\”The Headline in the Blue box\”, blocking=True)\n"; 
    my_str+= "end\n";

    The exact syntax I don't know because I don't know much about c++


  • TomTom Posts: 3 Apprentice
    VT,thanks a lot! I'm ok now,  it lacked a ')' in my code. Thanks again.
Sign In or Register to comment.
Left ArrowBack to discussions page