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:

 Contribute moderator Option 1 \$50.00 SGDOption 2 \$100.00 SGDOption 3 \$500.00 SGD

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

## 36 comments

1. Anandan says:

Hello zacobria,
I’m trying to establish a connection between my PC and my UR5 robot, I’ve done the programming as per the zacobria forum, but it’s throwing an error “syntax error in line 19: open:=socket_open(“127.0.0.1″,21) ” what should I do ?

1. zacobria says:

Hello Anandan

Thanks for the question.

Which article and program are you refering to ?

The IP address of 127.0.0.1 and port 21 does not look to be valid for a robot.

Which software are you using to connect to the robot ?

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

Also check out the CB3 forum

2. Fausto says:

Hi, maybe this question isn’t proper for this topic, but I don’t know were I can ask this.
How can I define a user reference frame?
There is a way to do it with a function or I must do it calculate all distances?
Thanks.

Fausto Fois.

1. zacobria says:

Hi Fausto

Thanks for the question.

On the Universal-Robots it is possible to set planes and also change the planes. Some examples at these links.

http://www.zacobria.com/universal-robots-knowledge-base-tech-support-forum-hints-tips/knowledge-base/planes-and-position-variables-1/

http://www.zacobria.com/universal-robots-knowledge-base-tech-support-forum-hints-tips/knowledge-base/planes-and-position-variables-2/

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

Also check out the CB3 forum

3. safa says:

Hello,

I am trying to rotate the gripper attached on a UR10. But what i noticed is that when the angle exceeds 90° or when in anti-clockwise, the gripper position shifts (1-2 mm) whithout a change in the X-Y values. Is that normal?

1. zacobria says:

Hello safa

Thanks for the question.

Which command is used to move the robot ?

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

Also check out the CB3 forum

1. Landon says:

Hi

We have a UR 10 that we are trying to get to rotate a tool around a single point. It does 100 degrees of rotation very evenly, but after that it seems to drift to one side by a couple of millimeters. Is this expected if the TCP never actually moves to different points ?

1. zacobria says:

Hi Landon

Thanks for the question.

If it is only the last joint (Wrist 3) that is turning then it is normally possible to make a full turn smoothly.

Hw is the code for the turn ?

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

Also check out the CB3 forum

1. Landon says:

The tcp is offset from the robot in the x direction, so for the tcp to rotate around the object all of the joints must move.

Robot Program
Waypoint_4
Waypoint_1
start_pose := get_actual_tcp_pose()
rz:= d2r(115)
movepose:=pose_trans(start_pose,p[0,0,0,00,rz])
MoveL
movepose

2. zacobria says:

Hi Landon

Thanks for contribution to the forum

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

Also check out the CB3 forum

4. Hawkey says:

Hello Zacobria,

I´m running the following program on my UR10:

MoveJ
startposition

VISOR_CommandSocket_open()
VISOR_setTrigger()
VISOR_CommandSocket_close()

VISOR_ResultSocket_open()
result_VISOR = socket_read_ascii_float(3, “VISOR_ResultSocket”)
result_Meter = [result_VISOR[1]/1000, result_VISOR[2]/1000, 0]
objectPosition = p[-result_Meter[1], 0, 0, 0, 0, 0]
VISOR_ResultSocket_close()

pos_NewObject = pose_add(startposition, objectPosition)

MoveL
pos_NewObject

Coordinates:
startposition p[304.55, -631.08, 42.93, 0, 0, 1.4843]
pos_NewObject [276.0, -631.08, 42.93, 0, 0, 1.4843]

My problem is that the robot moves in the z-axis and not in the x-axis.
How can I fix this?

Greetings Hawkey

1. zacobria says:

Hello Hawkey

Thanks for the question.

You might consider the pose_trans or pose_add function.

There is an example at this link, but used on the Rz parameter.

http://www.zacobria.com/universal-robots-knowledge-base-tech-support-forum-hints-tips/knowledge-base/script-client-server/

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

Also check out the CB3 forum

1. Hawkey says:

Hello zacobria,

that was not the problem.
I found out that the Robot needs his new positions in meter and not in millimeter.

So i just divided my positions by 1000 and now the robot does exactly what i wanted him to do

Thank you very much for spending your time on my little program

Greetings

Hawkey

5. Clay says:

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. zacobria says:

Hi Clay

Are the entire program the same on the UR10 – UR5 and UR3 ?

Have you analyzed the calculated position when it happens ?

Can it be that the calculated position might be valid for UR5 and UR10 but not valid for UR3 ? – maybe because of the shorter reach ?

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

Also check out the CB3 forum

1. Clay says:

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

1. Clay says:

Are there any particulars to look for in the program?

2. zacobria says:

? – Haven´t seen the entire program

6. speedyhoopster says:

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. zacobria says:

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. speedyhoopster says:

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 ?

7. Sandrine says:

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. zacobria says:

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 ?

8. Sandrine says:

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. zacobria says:

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 ?

9. Sandrine says:

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. Sandrine says:

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. zacobria says:

Hello Sandrine

Then it might be a syntax error. Are you using an “Assignment” or using a “Script” method for the variable – maybe check the assignment operator.

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

Also check out the CB3 forum

1. Sandrine says:

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. zacobria says:

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. Clay says:

I have the same issue on a UR3. Has anyone solved this yet?

4. zacobria says:

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

5. zacobria says:

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