Home Programming

Discussion

Left ArrowBack to discussions page
VT_340VT_340 Posts: 24 Apprentice
edited June 2017 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

<1
  • BeachChEBeachChE Founding Pro Posts: 19 Handy
    Look at using a MoveP command.
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 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: 24 Apprentice
    edited May 2017
    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 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 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: 24 Apprentice
    Are there any more informations about how to load a SCRIPT program via TCP and how to play it? 
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 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: 24 Apprentice
    edited May 2017
    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: 24 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: 24 Apprentice
    edited June 2017

    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 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    edited June 2017
    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: 24 Apprentice
    edited June 2017
    HA!  now the TCP  follows a line that I generated before in python. Thanks a lot.
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 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: 24 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: 24 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: 24 Apprentice
    edited November 2017
    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: 5 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:

    <span class="post-font-size-large">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</span>

    Could you help me out?

    Tom

  • VT_340VT_340 Posts: 24 Apprentice
    edited November 2017
    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: 5 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: 24 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: 5 Apprentice
    VT,thanks a lot! I'm ok now,  it lacked a ')' in my code. Thanks again.
  • TomTom Posts: 5 Apprentice
    VT_340 said:
    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?
    Hi, VT, I encountered a new problem,I want to change my path realtime, but when I used function(servoj()) to update the former motion instructions (servoj()),the UR5 came to a hold, how can I do to make UR5 move without any hold ?
    the former motion function:
    def trajPlan():
      servoj(get_inverse_kin(p[0.38767,0.03974,0.23083,-0.99513,1.27173,-0.84444]),t=2)
      servoj(get_inverse_kin(p[0.43628,0.04444,0.23922,-0.99513,1.27173,-0.84444]),t=2)
    end
    
    the latter motion function:
    def trajPlan():
      servoj(get_inverse_kin(p[0.48489,0.04914,0.24760,-0.99513,1.27173,-0.84444]),t=2)
      servoj(get_inverse_kin(p[0.53202,0.04915,0.24760,-0.99516,1.27173,-0.84446]),t=2)
    end
    



  • VT_340VT_340 Posts: 24 Apprentice
    Maybe you want to use the ROS driver for your problem. You do not need to get into ROS completely but you can use the driver for a proper communication between your code and the robot.
  • TomTom Posts: 5 Apprentice
    VT_340 said:
    Maybe you want to use the ROS driver for your problem. You do not need to get into ROS completely but you can use the driver for a proper communication between your code and the robot.
    Thanks, I'll try it.
  • nedaesnedaes Posts: 7 Apprentice
    VT_340 said:
    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?
    Hi VT_340,
    I had the same problem as you but I couldn't fix it. I am trying to publish a path including many points for UR5 and execute them by using Servoj.
    In this regard, I defined a talker to translate a gcode file to robot positions and publish them one by one. But I still have jerks in each point (the same as using Move commands). As I read in UR5 document, the main shape of servoj command is as below:
    < servoj(q, a, v, t=0.008, lookahead_time=0.1, gain=300) >
    I think my problem is related to calculating time. Why did you choose t=0.05 sec? And how should I define it to prevent unwanted stopping or jerky movements for each point?
     

  • VT_340VT_340 Posts: 24 Apprentice
    Hi!

    I think there is a reason why ROS controls the UR robot in the way it does: It uploads a URScript program to the robot which opens a port for sending data to AND is solving the jerk issue by using threads. I never really understood how it works, but it works. Check it out on Github. I don't know if there are other ways to solve the problem, but in general the UR-Robots are made for Pick-And-Place tasks.. if you want to go beyond that, it is possible, but not well documented and it can become tricky.
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    nedaes said:
    I had the same problem as you but I couldn't fix it. I am trying to publish a path including many points for UR5 and execute them by using Servoj.
    In this regard, I defined a talker to translate a gcode file to robot positions and publish them one by one. But I still have jerks in each point (the same as using Move commands). 
    @nedaes how fast are you translating your points for the robot?  The servoj is expecting to receive time slice data, preferably at 125 Hz, if you are just taking the points from G-code and converting them into positions for the robot that could be leading to your jerkiness that you are seeing as you are not giving it the same distance to be covered in the same time slice.  My understanding of the "t" parameter is that is telling the robot how long the command you just sent should take to execute.  So if you are giving it t=0.008 and not actually giving it the distance you want to cover in 8 ms than you are going to see jerky motion as the speed of the robot is not staying consistent.  At least that has been my observation with using the servoj functionality.
  • nedaesnedaes Posts: 7 Apprentice
    VT_340 said:
    Hi!

    I think there is a reason why ROS controls the UR robot in the way it does: It uploads a URScript program to the robot which opens a port for sending data to AND is solving the jerk issue by using threads. I never really understood how it works, but it works. Check it out on Github. I don't know if there are other ways to solve the problem, but in general the UR-Robots are made for Pick-And-Place tasks.. if you want to go beyond that, it is possible, but not well documented and it can become tricky.
    Thanks for your prompt reply!
     I tested different times and I chose t = 0.1 as a candidate. It produces less fluctuation for movements. I hope that I can find out the logic behind this.
Sign In or Register to comment.
Left ArrowBack to discussions page