Reading Global Variables from Python project

Hello everyone!
I have a global variable called: Force_Limit inside my program and I am trying to read its value from my Python program. I have created to following Python script:


It produces the following output:

the force limit is: b’\x00\x00\x007\x14\xff\xff\xff\xff\xff\xff\xff\xff\xfe\x03\tURControl\x03\x0f\x00\x00\x00\x08\x00\x00\x00\x0014-06-2022,

Is there a fault with my logic or am I simply using the wrong function to get the variable ? I would like to read this variable and get the integer value (also can anyone explain what is this protocol message I am getting ? and how do I decode it ?)

Thank you for your answers in advance.

There is a bit of a conceptual misunderstanding.

Universal Robots’ offers various methods for interfacing with external devices, and in this case, you are utilizing their primary client interface. In the given scenario, your Python code serves as the client, while the robot’s controller unit acts as the server. An internal process within the robot constantly listens for request messages on port 30002, enabling communication between the client and the server.

As you have figured out, the client can send URScript commands to the server for execution. Unfortunately, receiving data from the server with the client is not as simple; the approach on line 20 will not work. The server periodically sends messages containing robot data to all connected clients. These messages are transmitted as hexadecimal strings representing binary data about the robot’s state, which is what you are observing in your console. The variables coded into these messages are predefined as outlined in their spec. You would need to receive the entire message then decode it. I wrote this which has a few examples.

The URScript socket_get_var() is intended to be used inside a running robot program where the robot is the client and an external device is acting as the server. The robot’s program will say x = socket_get_var("POS_X") and the python server would respond something like server_socket.sendall(b"POS_X 20\n") which would store 20 into the robot’s variable x.

Thank you for clearing it up quickly.