# Return values from URScript

**URL:** <https://forum.universal-robots.com/t/return-values-from-urscript/22019>\
**Category:** Robot Communication\
**Created:** [June 16, 2022, 2:02pm UTC](https://forum.universal-robots.com/t/return-values-from-urscript/22019 "2022-06-16T14:02:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon22203897](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@anon22203897](https://forum.universal-robots.com/u/anon22203897)\
**Post date:** [June 16, 2022, 2:02pm UTC](https://forum.universal-robots.com/t/return-values-from-urscript/22019/1 "2022-06-16T14:02:26Z")

</div>

Hi, I have successfully been able to send URScript commands to the robot via the primary interface, and can read the returned byte stream. However, I do not know where to read return values from URScript commands, such as is\_steady which returns a bool or get\_actual\_tcp\_pose which returns a 6d vector. Where do I see these return values?

---

<div class="post-metadata">

**Author:** ![SynchMaster](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@SynchMaster](https://forum.universal-robots.com/u/SynchMaster)\
**Post date:** [June 17, 2022, 6:29am UTC](https://forum.universal-robots.com/t/return-values-from-urscript/22019/2 "2022-06-17T06:29:46Z")

</div>

Where do you want to “see” this return values?

---

<div class="post-metadata">

**Author:** ![anon95420709](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@anon95420709](https://forum.universal-robots.com/u/anon95420709)\
**Post date:** [June 17, 2022, 6:36am UTC](https://forum.universal-robots.com/t/return-values-from-urscript/22019/3 "2022-06-17T06:36:35Z")

</div>

Hi, I have the same problem. I am using ur\_rtde python package to control the robot. I can use `sendScriptCommand` (_const_ std::string &_cmd\_str_ ) to send script to the controller. But I want to use ur math of script command to do some calculation on tool vector. I don’t know how I can get the return value after sending the script.

---

<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:** [June 17, 2022, 7:10am UTC](https://forum.universal-robots.com/t/return-values-from-urscript/22019/4 "2022-06-17T07:10:53Z")

</div>

Primary Interface does not return values. On the other hand, many information are streamed (positions, status, inputs and outputs, …)  
Alternatively, to get the result, you can put it in a variable and get this variable from Primary Interface (or Dasboard server).

For example with [this library](https://underautomation.com), it would look like :

```auto
var robot = new UR();
var param = new ConnectParameters("192.168.0.56");
param.PrimaryInterface.Enable = true;

// connect to the robot with Dashboard and Primary Interface protocols
robot.Connect(param);

// Remote execute script that sets variable "myVar"
robot.PrimaryInterface.Script.Send("global myVar = get_actual_tcp_pose()");

// wait program execution
Thread.Sleep(1000);

// Read MyVar value
var myVarValue = robot.PrimaryInterface.GlobalVariables.GetByName("myVar");

// if myVar exists in the robot
if (myVarValue != null)
{
    // As myVar is here a pose, you can cast it to a pose object
    Pose myVarPose = myVarValue.ToPose();

    Console.WriteLine($"X = {myVarPose.X}");
    Console.WriteLine($"Y = {myVarPose.Y}");
    Console.WriteLine($"Z = {myVarPose.Z}");
    Console.WriteLine($"Rx = {myVarPose.Rx}");
    Console.WriteLine($"Ry = {myVarPose.Ry}");
    Console.WriteLine($"Rz = {myVarPose.Rz}");
}

```
