Changing TCP in urscript to TCP already created in the system

Usually in other robot environments its possible to get the Tool pose by reference from within their system. To my knowledge this isn’t possible with urscript?
I have tried to manually define the TCP pose as a variable but when given the same name as it is specified in the TCP it says that a variable of that name already exists…, but if it says there is a variable with that name why can’t I access it within the urscript?

filipe.jorge,
I’m not quite sure what your asking exactly!

You can easily get the TCP pose by using the get_tcp_actual_pose() scrip you can assign it to a variable by writing
Variable_name = get_tcp_actual_pose()

this will give you the position of the TCP relative to the Base of your Robot.

do you have a copy of the UR Script manual?
https://www.universal-robots.com/download/manuals-e-series/script/script-manual-e-series-sw-511/

That would require for the TCP to be set before running the script.

Imagine this, you create multiple TCP’s using the console (using the UR measure tools for example), but the only way I find to change tool in urscript is to copy the values from the TCP into a variable manually, and then set_tcp(variable). For example in Kuka I would change the tool in code with “$TOOL = TOOL_DATA[7”], in Yaskawa “///TOOL 7”, etc…

Since a name is assigned to the TCP, and this name cannot be reused as a global variable, why can’t I access it in urscript, or why can’t I access the specific TCP with an ID_Number…

Edit: Also I forgot to specify that I do have a copy of the urscript manual.

filipe.jorge,
Yes I understand your problem
the UR does lack some of the capabilities you would find in most industrial robot controllers.
Make a request for what you want on the wish list and UR might consider adding it to future software releases.

You can set a TCP in the the program with the SET node (set no action and then set the TCP you want)
however I suspect you want to set the TCP based on certain conditions.

I have a crude solution.

You could create a Matrix of positions
TCP_List = [p[0,0,0,0,0,0,],p[0,0,0,0,0,0,],p[0,0,0,0,0,0,]] as many tools as required.
then set the TCP (as described above)
then write the TCP value to the List
TCP_List[i] = get_tcp_offset
repeat until your list is full
then when you want to call the required TCP
write set_tcp = TCP_List[*]

hope this helps

That is kinda what I have been doing, except more manually beacuse I just copy paste the values that calibrating the tool gave me and manually code them into the urscript.
Thank you for the tip, I was just hoping something like that would exist in their environment to make my life easier.

Glad I could help
I would imagine something like this could be easily done in a URCap but I have no experience in writing one

filipe.jorge,
I know it’s been a while since I last commented on this so if you have a solution that’s great.

but it just so happens I came upon the issue for myself when needing to dynamically adjust my TCP.

this is the solution I came up with to create a variable with TCP Data.
I firstly created a Flange TCP with X=0, Y=0, Z=0, Rx=0, Ry=0, Rz=0 in the installation tab TCP
then Created my Tools TCP with the TCP Wizard.

then in my program wrote the following (as a test program)

Program
Variables Setup
Robot Program
MoveJ
Waypoint_3
Get TCP Value
‘Set TCP To Flange TCP’
Set
toolvar1≔Tool_const
‘Set TCP To Tool TCP’
Set
toolvar2≔Tool_const
‘Calculate TCP Values’
Tool_TCP≔pose_inv(pose_sub(toolvar1, toolvar2))
MoveJ
Waypoint_1
Wait: 1.0
‘Move to Pos with Tool TCP’
Wait: 1.0
MoveL
Waypoint_2
TCP Offset Input
‘enter TCP offset values’
X_shift≔’X Distance to offset TCP’
Y_shift≔’Y Distance to offset TCP’
Z_shift≔’Z Distance to offset TCP’
Tool_TCP[0]=Tool_TCP[0]+(X_shift/1000)
Tool_TCP[1]=Tool_TCP[1]+(Y_shift/1000)
Tool_TCP[2]=Tool_TCP[2]+(Z_shift/1000)
‘Set TCP with offset values’
set_tcp(Tool_TCP)
‘Move to Pos with Active TCP’
MoveL
Waypoint_2
Wait: 3.0

You could loop this section to populate a TCP_List instead of having to type it in manually every time you adjust or add a TCP in the installation tab
Set
toolvar2≔Tool_const
‘Calculate TCP Values’
Tool_TCP≔pose_inv(pose_sub(toolvar1, toolvar2))

1 Like