How to update an instalation variable using ur Script commands

Is it possible to update an instalation variable using script commands with TCP (eg: using packetsender)?

3 Likes

Yes is the answer.

  1. from within a program use a script command to assign a value to the already defined installation variable
  2. from a computer connected to port 30001-30003 and if no program is running on the robot controller, issue a script command assigning the variable.
  3. from a computer connected to port 30001-30003 and if a program is running on the robot controller, issue a script secondary function assigning the variable. Secondary program - 17257
1 Like

@pho Assign a value to an installation variable from a secondary program doesn’t work.
To test it I defines the installation variable “var1”, then I send on port 30001 a secondary program

sec set_value():
global var1=2
end

The value in installation variable tab is not modified.
If I replaces “sec” with “def”, now it works.
Should it be possible to modify an installation variable from a secondary program ?
I have a use case where it would be useful

@pho Just like malacaasse I would like to know if this is possible.

Hello,

I’m using polyscope 5.12, and it seems that even with the “def” type function it doesn’t work.
Do you always use this way to modify an installation variable?
Do you have python script to share ? maybe I am doing something wrong…

Which solution did you choose to modify an installation variable when a program is already running since sec does not work?

I think I’am going to use a socket server on my computer and a socket exchange with the robot using the dashboard server to run remotely the program on the robot.

Thanks

I created a program on the robot that changes the installation variable and downloaded it to my computer to check what’s inside.

On the second line of the program there is a specific assignment.

def load_variables():
global _hidden_verificationVariable=0
global i_var_1=999
…
end

The variable _hidden_verificationVariable is not documented at all, it seems to be an internal ur variable.
With this specific assignment the installation variable is correctly modified on the robot when I send the script through socket to the primary/secondary/rtde interface.

By default the value _hidden_verificationVariable is set to 1.

It seems that is not working with secondary programs : sec program(): …

Can I get a sample?
Don’t stop the robot program?

Hello,

My python function is :

import socket
ip_robot = "192.168.1.2"
port_robot = 30001  # primary interface

def send_urscript(urscript_text: str) -> bool:
    """send a single line or a program through socket  : def my_prog():\n\tcmd\n\t ... end\n"""
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as socket_robot:    
        socket_robot.connect((ip_robot, port_robot))
        program_text = urscript_text.encode("utf-8")
        socket_robot.send(program_text)
        socket_robot.close()
    return True

My program text :

program_text = f"""def myprog():
\tglobal _hidden_verificationVariable=0
\tglobal g_nb_screw=8
end
"""

And the call :
end_urscript_fmo(program_text)

As said the in my previous, it does not seem to work with secondary programs.
So the program stops when you send the def function on the socket.

Hello,
Thank you for your reply.

I want to read and write installation variables from host PC with LabVIEW and without stopping the UR program.

Best Regards,

Hello,

If you find a way to do that, I am interested by the solution :slight_smile:

Regards

RTDE_20221207.pdf (261.6 KB)

Success read and write register by RTDE.