Get variable from UR Script


I have a external axis which i can control over Modbus TCP. I can also read the actual position from this axis and save the value in a variable. Now i want to display this value in my URCap and refresh it for example every second. Now i want to know how this is best implemented.

  1. Should I implement a loop in my URCap and use the scriptCommunicator?

  2. Daemon?

  3. Socket?

  4. Any other suggestions?

Thanks for your help.

In my experience, socket communication is very slow, and if used rapidly like you’re suggesting, will bog the system down very badly. I’m not sure what the difference is between the scriptCommunicator and sockets though. Are those not the same thing?

I have a feeling the answer will be “Use the RTDE” hur dur but since there’s like 0 documentation on implementing it via Java, I have never been able to get it working, and therefore I hate that answer lol. Keep us posted if you figure something out, because there’s several things I’ve wanted to use this for but ended up settling on sending a socket command on openView() or other one-shot based controls.

1 Like

Hello, thank you for your answer.

I implemented it now with the scriptCommunicator. But as you have already mentioned the performance is really bad. Especially when I have to transfer more than one variable.

What do you think about a daemon with XML-RPC? This is according to the documentation also a socket communication. Do you have any experience with the performance from a daemon process? Is it possible to get variables from the URScript about a daemon?

I used XML-RPC with Java running as the server (so not using a daemon) and there was still a bit of lag if I remember correctly. I do think I was able to fix it though. But I was just sending a single variable once every so often, not multiple every second. Maybe it would work, I just haven’t tried.