Universal Robots Forum

String to pose variable

We are using a PC to set teach points on the UR through a TCP socket. The teach points already defined on the robot.
We would like to send down the name of the teach point and pose data (p[0,0,0,0,0,0]) through TCP as a string. We parse the string to separate the name and position. Then we want to assign the pose to the name we just sent down.
For example:
We send “W1, 1,1,1,2,2,2”

How can I get this to work. I attached a picture of different things I’ve tried.


String concatenation in urscript does not work the ‘pythonic’ or java way using the + operator. you have to use str_cat() to do so :wink:
There are also several other issues. you cant define a variable name with ‘on the fly’ concatenation. Also, if you overrwite the mystring variable on attempt 2 the “W1” is gone.
Using W1_p=p[0,0,0,0,0,0] works because you overwrite a auto generated variable name with a cartesian pose.

what should work is sth like:
def test(x,y,z,rx,ry,rz):
mypose = p[x,y,z,rx,ry,rz]
movej(get_inverse_kin(mypose),a=1.4, v=1.05)
But why do you even mix UrScript with polyscope generated waypoints ? you can send the whole stack of script through the socket without even using the programming interface by activating the remote control.

1 Like