1. Home
  2. Knowledge Base
  3. Position variables 1

Universal-Robots  – Position variables 1:

Application Description:
This article uses variables and lists (also sometimes reffered to as “arrays”) to create waypoints and how variable waypoints can be manipulated with an offset defined in the variables.

The Universal-Robots is a 6 axis robot which means it has 6 turning joints. Therefore a position can be described with a set of data in a list – either as joint angles – or as a pose with cartisian cordinates. Such list can be –

[j1, j2, j3, j4, j5, j6] when representing the robot position with joint angles.

p[X, Y, Z, Rx, Ry, Rz] when representing the robot position with cartisian cordinates also called a “Pose”.

Notice the “p” in front of the second list indicationg that it is a Pose representation.

This examples will use the Pose representation.

Function description:
This application shows how the robot moves from a starting position with three different size of increments  depending on the status of the Inputs DI1, DI2 and DI3. When an input is selected the robot will move in increments according to the input set which is associated to a variable.
If input 0 is set the robot moves in X direction with increments of 0.1 mm.
If input 1 is set the robot moves in X direction with increments of 1 mm.
If input 2 is set the robot moves in X direction with increments of 5 mm.

I/O table Inputs:
DI0 = Move in increments of 0.1 mm.
DI1 = Move in increments of 1 mm.
DI2 = Move in increments of 5 mm.

I/O table Outputs:

Not used.

Variable Table:
Var_1 = Starting position.
Var_2 = X increments of 0.1mm.
Var_3 = X increments of 1mm.
Var_4 = x increments of 5mm.

Variable Waypoints:
Var_10 = New position after increment.

Program description:
In the Before Start sequence the variables are defined where Var_1 is a starting position (Pose). Var_2 is defined as X= 0.1mm. Var_3 is defined as X=1mm and Var_4 is defined as X=5mm. The robot moves to starting position var_1.

In the robot program – the program loops forever and checks the status of the inputs with “IF” statements. When an input is set high the variable var_10 is pose_transfered with the associated variable – for example if input 0 is set high – then var_10 is pose_transfered with var_2 (which represent 0.1mm). Then the robot moves to position var_10. And var_1 is assigned the value of the new position in order to be the origin for the next increment.

Same is the case when input 1 and input 2 is true, but with their respective associated variables for increments of 1 mm and 5 mm.

Notice:
The “Tool speed” is set to 10mm/s in this case in order to obtain a smooth move. This value can be considered to be adjusted according to the increment and desired speed.

This example was made on a UR3 robot. If using a UR5 or UR10 the starting position var_1 might need to be further away from the base.

Program code:
universal-robots-program-working-with-variables-1

Disclaimer: While the Zacobria Pte. Ltd. believes that information and guidance provided is correct, parties must rely upon their skill and judgement when making use of them. Zacobria Pte. Ltd. assumes no liability for loss or damage caused by error or omission, whether such an error or omission is the result of negligence or any other cause. Where reference is made to legislation it is not to be considered as legal advice. Any and all such liability is disclaimed.

If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.

Author:
By Zacobria Lars Skovsgaard
Accredited Universal Robots support Centre and Forum.

Also check out the CB3 forum



Was this article helpful?

23 comments

  1. Thanks for the response. Our robot uses the before start routine to move itself to its current position. Using the get pose and making a variable equal to the position.
    Then continues through the rest of the program .
    It may run for several days or several weeks then we will get the yellow dot on the variable with an error stating that the variable is not a valid position. Tje only way we can clear this is to reload the program from a backup. This is on a UR3. We have two UT10s with the same before start routine and never have this issue. I can send file if you would like to see.

      1. Hi, no I have not analyzed the position when the error occurs. I will do so the next time that I am present when they have the error.
        Other than the before start portion the programs are completely different.

        Program
        Init Variables
        BeforeStart
        Move_To_Home
        CurPos≔get_actual_tcp_pose()
        Wait: 0.01
        MoveL
        CurPos

  2. Hello zacobria,

    is there a way to make a break( short pause) in between the movement from one Waypoint to another one?
    So my Plan is to start from A and to a random time i need to “break” the movement, but want to go on at the same place i had the break?!
    Is there a way? That would be so great.

    Speedy

    1. Hello Danilo Hoss

      Thanks for your question.

      It is possible to use the option “Check expression continuously” for a “If” statement.

      If the “to” waypoint is under a “If” statement with the “Check expression continuously” active then when the condition for the “If” is true the robot will start move towards the waypoint – then when the condition is no longer true the robot will branch out of the “If” immediately. Then a “Wait” or “Stopj” or other actions can be preformed and then have the robot to return to “If” statement with the “to” waypoint – and the robot will continue towards that waypoint.

      Author:
      By Zacobria Lars Skovsgaard
      Accredited Universal Robots support Centre and Forum.

      Also check out the CB3 forum

      1. Hello,
        okay perfekt that is perfect!
        Is this only possible for one waypoint or can i do this for more than one under the if statement ?
        If this is possible can i jump directly to a part in the Programm ?

  3. Can you please send me an email, so I can send you pictures of the last occurence today?
    There is obviously a problem between script and pose coordinates generated by script, we will add a conditionnal command in the script, if the value is too small, then overwrite it with 0.
    But the problem remains…

    1. Can you list the entire program ?

      Do I understand correct that when you say “execution screen” that is under the “Program Tab” is that correct ?

      What is the tab label of the second screen ?

  4. Yes, the robot stops, no message explaining why, and then code becomes yellow, with no possibility to run again, we have to cut/copy the command (without changes), and press run, then it works!

    The robot runs in execution screen, and variables are on second screen.
    For the exact coordinates where it happens, you will have to wait, as it does not happen every time.

    1. Can you list the entire program ?

      Do I understand correct that when you say “execution screen” that is under the “Program Tab” is that correct ?

      What is the tab label of the second screen ?

  5. Hello,

    On a UR5 application, we have an issue with a variable which is calculated in a script, the value is very small, represented by -3.822E-4 in the result, but Gui can’t obviously understand this value, we get an error message.

    partial code:
    p_pose_mes=pose_trans(pose_inv(pose_frame),pose_outil)

    and
    p_der_mag_al[2]=p_pose_mes[2]

    The issue is with p_der_mag_al

      1. It seems the code is not compiled, branch appearing in yellow, as th cobot was working just before!
        I have checked the log file, and no error message did mention it.

          1. No, code is correct (in a script)
            p_pose_mes=pose_trans(pose_inv(pose_frame),pose_outil)
            p_der_pr_mag_al[2]=p_pose_mes[2]

            The value of p_der_mag_al is the problem.

            the cobot is on run when error appears, the calculated variable on screen is written with E, because too small, and this value cannot be interpreted as a coordinate.
            How can I limit the number of decimals?

          2. Yes “E” means a small number that is correct.

            Is the line still yellow as you mentioned earlier ?

            Or how do you experience the error – does the robot stop ?

            Or if the program runs as you also mentioned – is there a messages when the error appears ?

            Which screen (tab) do you see the calculated variable ?

            What is the X, Y, Z, Rx, Ry, Rz position of the robot when it happens ?

          3. Can you list the entire program code ?

            How do you experience the error – does the robot stop ?

            Does the program beginn to execute ?

            Is there a messages when the error appears ?

            Which screen (tab) do you see the “E” value ?

            What is the X, Y, Z, Rx, Ry, Rz position of the robot when it happens ?

            Author:
            By Zacobria Lars Skovsgaard
            Accredited Universal Robots support Centre and Forum.

            Also check out the CB3 forum

          4. Hi Clay and Sandrine

            Based on the few lines of code as informed in the question from Sandrine – I have tried a program similar like this below.

            Program
            Robot Program
            MoveJ
            Wait: 0.01
            Waypoint_1
            pose_outil≔p[0,0,0.2,0,0,0]
            p_der_mag_al≔get_actual_tcp_pose()
            Wait: 2.0
            pose_frame≔get_actual_tcp_pose()
            p_pose_mes≔pose_trans(pose_inv(pose_frame),pose_outil)
            Wait: 3.0
            p_der_mag_al[2]=p_pose_mes[2]
            p_der_mag_al
            pose_frame≔get_actual_tcp_pose()
            Wait: 3.0

            When I run this program on a real robot the value of the variables shifts between values that also have very small figures represented with “E” like these figures.

            pose_frame:p[-2.6015938E-5, -0.34999007, 0.24998203, 1.6202765E-4, -3.1415684, -7.198867E-5]
            p_pose_mes:p[-6.3331754E-5, 0.34998778, 0.049998075, -1.6202765E-4, 3.1415684, 7.198867E-5]
            p_der_mag_al:p[-2.9297025E-5, -0.34999648, 0.24999486, 1.4315585E-4, -3.1415904, -1.0521646E-6]

            pose_frame:p[1.282977E-5, -0.3499559, 0.049987607, -2.5449067E-4, 3.1415017, 1.900056E-4]
            p_pose_mes:p[-6.3331754E-5, 0.34998778, 0.049998075, -1.6202765E-4, 3.1415684, 7.198867E-5]
            p_der_mag_al:p[-2.9297025E-5, -0.34999648, 0.049998075, 1.4315585E-4, -3.1415904, -1.0521646E-6]

            (Also notice the Z value changes with the value of 0.2 as per the variable pose_outil).

            And the robot program performes as expected without any error messages and the robot moves between the waypoints.

            Author:
            By Zacobria Lars Skovsgaard
            Accredited Universal Robots support Centre and Forum.

            Also check out the CB3 forum

Leave a Reply

Your email address will not be published. Required fields are marked *