# Getting Variables from a program

**URL:** <https://forum.universal-robots.com/t/getting-variables-from-a-program/31470>\
**Category:** Technical Questions\
**Created:** [November 20, 2023, 4:48pm UTC](https://forum.universal-robots.com/t/getting-variables-from-a-program/31470 "2023-11-20T16:48:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PMonforte](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@PMonforte](https://forum.universal-robots.com/u/PMonforte)\
**Post date:** [November 20, 2023, 4:48pm UTC](https://forum.universal-robots.com/t/getting-variables-from-a-program/31470/1 "2023-11-20T16:48:28Z")

</div>

Greetings URCommunity,  
In older polyscope versions I was able to retrieve a variable from a program I sent via TCP/IP port 30003. For instance,  
If I created the program  
def program():  
global var\_1 = “string\_test”  
halt  
end  
And if I sent it via 30003 and then used the command getVariable string\_test of the Dashboard port (29999) I could get this value. But a robot my company bought a few months ago has a different polyscope/software version and this is no longer possible, the reason for which lies in the fact the variable no longer shows up in the variable section whereas in older robots it does. Thus, it’s as if the variable does not exist.  
Can this be reversible?  
I look forward to hearing from you  
Best regards  
Pedro Monforte

---

<div class="post-metadata">

**Author:** ![mmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mmi/32/691_2.png) [@mmi](https://forum.universal-robots.com/u/mmi)\
**Post date:** [November 21, 2023, 8:39am UTC](https://forum.universal-robots.com/t/getting-variables-from-a-program/31470/2 "2023-11-21T08:39:57Z")

</div>

Since release 5.13.0 Polyscope rejects global variables from programs started externally.  
Check “compatibility notice” in release notes: [Release Notes 5.13.0](https://www.universal-robots.com/articles/ur/release-notes/release-note-software-version-513xx/)  
There are many other ways to get feedback from program ran on the robot.

- use general purpose variables
- use xmlrpc, or socket connection to external server

Note that “getvariable” is not on the list of supported dashboard server commands, and is not guaranteed to be backwards compatible.

---

<div class="post-metadata">

**Author:** ![PMonforte](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@PMonforte](https://forum.universal-robots.com/u/PMonforte)\
**Post date:** [November 21, 2023, 9:20am UTC](https://forum.universal-robots.com/t/getting-variables-from-a-program/31470/3 "2023-11-21T09:20:25Z")

</div>

Thank you very much for your reply. I indeed noticed that the getVariable command was not listed on the Dashboard manual and I came across it by chance in this forum, though it was truly useful.  
My issue is the following: my program works in an app which generates a script and sends it to the robot and it’s absolutely necessary to be this way; it can’t be done otherwise.

I suppose thus that general purpose variables are excluded, but is the xmlrpc method possible? I had a quick look over it and it seems to work with Python, C and C++ but not with C# which is the language I’m using. This is also untradeable. The reason I needed this is because I am using a pose\_trans and I am finding it difficult to calculate mathematically (I’ve posted about this a few days ago, and people have directed me to related posts, but still I have not managed to get it done)

Thank you again for your collaboration  
Best regards  
Pedro Monforte

---

<div class="post-metadata">

**Author:** ![mmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mmi/32/691_2.png) [@mmi](https://forum.universal-robots.com/u/mmi)\
**Post date:** [November 21, 2023, 10:31am UTC](https://forum.universal-robots.com/t/getting-variables-from-a-program/31470/4 "2023-11-21T10:31:48Z")

</div>

I can’t recommend any xmlrpc server for C#, but quick google gave some hope 😉  
Alternatively simple raw socket server interface could do the job.  
Use socket\_send\_line() with pose, and then parse on C# side.

---

<div class="post-metadata">

**Author:** ![PMonforte](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@PMonforte](https://forum.universal-robots.com/u/PMonforte)\
**Post date:** [November 21, 2023, 10:45am UTC](https://forum.universal-robots.com/t/getting-variables-from-a-program/31470/5 "2023-11-21T10:45:02Z")

</div>

Thank you for your reply. I seem to find a problem here, nonetheless. I’ll try to elaborate further.  
Let’s say I create a program with forty (40) waypoints. These points have their coordinates relative to Base. I then have to create a program in which I will send all these poses via Socket, apply the transformation to a new plane and then re-send them back to my app. I guess this could work but I’ll still try to transform the coordinates mathematically.

The problem I’ve been having is the following: I can transform the X,Y,Z values but not the Rx,Ry,Rz.

> [@Pose\_trans and pose\_inv functions in URCap](https://forum.universal-robots.com/t/pose-trans-and-pose-inv-functions-in-urcap/1257/2):
>
> For future readers, I managed to re-implement pose\_trans and pose\_inv in java. You first have to convert the pose to an affine transformation. To do this, you need to calculate the rotation vector as a 3x3 rotation matrix (see [Maths - AxisAngle to Matrix - Martin Baker](http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/index.htm)). Then you extend that 3x3 rotation matrix to the 4x4 affine transformation by adding a 4th column vector that corresponds to \<x,y,z,1\>, and a 4th row vector \<0,0,0,1\> so it looks like | R | T | |-------+---| | 0 0 0 | 1 …

This was helpful but only for x,y,z, not rx,ry,rz

Any help is much appreciated  
Best regards  
PM

---

<div class="post-metadata">

**Author:** ![androidflorent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/androidflorent/32/3314_2.png) [@androidflorent](https://forum.universal-robots.com/u/androidflorent)\
**Post date:** [January 22, 2025, 9:13am UTC](https://forum.universal-robots.com/t/getting-variables-from-a-program/31470/6 "2025-01-22T09:13:13Z")

</div>

Since you’re in C#, you can take a look at this library, which allows you to get the value of a global variable or a variable in your program, either through the Daskboard Server or the Primary Interface :

[https://underautomation.com/universal-robots/documentation/variables](https://underautomation.com/universal-robots/documentation/variables)
