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?
Where do you want to “see” this return values?
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.
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, it would look like :
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}");
}