Read variables

The SDK allows to read the installation variables and the program variables of the robot.

Get all variables

// Get all variables currently declared in the robot
GlobalVariable[] variables = _ur.GlobalVariables.GetAll();

Get one variable

// Get a variable by its name
GlobalVariable myVar = _ur.GlobalVariables.GetByName("myVar");
// Get its type and value
GlobalVariableTypes type = myVar.Type;
object value = myVar.Value;
// Convert it to pose
Pose poseValue = myVar.ToPose();

Try it with the Windows example

Classes

Members of GlobalVariable :
public class GlobalVariable : GlobalVariableValue {
// Variable name
public string Name { get; },
// Last time the variable was sampled
public TimeSpan Time { get; }
}
Members of GlobalVariableValue :
public class GlobalVariableValue {
// Returns variable value if type is Bool. Il type is Float or Int, it returns True if value is not 0. Else, it returns false
public bool ToBool(),
// Returns variable value if type is Float. Il type is int, it casts it to float. If Type is bool, it returns 1 or 0. Else it returns NaN
public float ToFloat(),
// Returns variable value if type is Int. Il type is Float, it tries to cast it to int. If Type is bool, it returns 1 or 0. Else it returns 0
public int ToInt(),
// Returns an array of GlobalVariableValue if Type is List. Else, null is returned
public GlobalVariableValue[] ToList(),
// Return variable value GlobalVariable[,] if variable is a matrix. First dimension is row index and second dimension is column index.
Use GetLength(0) to get row number and GetLength(1) to get column count
public Array ToMatrix(),
// Returns a Pose if Type is Pose. Else, null is returned
public Pose ToPose(),
// Returns a string that describes the variable, regardless of its type
public override string ToString(),
// Type of a variable
public GlobalVariableTypes Type { get; },
// Value of the variable
public object Value { get; }
}
Members of GlobalVariableTypes :
public enum GlobalVariableTypes {
// Variable value is bool
Bool = 4,
// Variable value is float
Float = 6,
// Variable value is int
Int = 5,
// Variable value is an array : GlobalVariableValue[]
List = 2,
// Variable value is a matrix
Matrix = 7,
// Variable value is null, the value has not been assigned yet
None = 0,
// Variable value is a UnderAutomation.UniversalRobots.Pose
Pose = 3,
// Variable value is a System.String
String = 1
}
Members of GlobalVariables :
public class GlobalVariables {
// Indicates which decoder is used used to read variables according to firmware version
public GlobalVariablesFirmwareVersion FirmwareVersion { get; },
// Returns a list of all variables declared in the robot
public GlobalVariable[] GetAll(),
// Get a variable by its name. Null is returned if the bariable doesn't exist
public GlobalVariable GetByName(string name),
// Event raised whan the variable list changed. For example, after a program starts
public event EventHandler<GlobalVariablesEventArgs> ListUpdated,
// Return a string where each line contains type, name and variable value
public override string ToString(),
// Event raised at 10Hz when variable values are updated
public event EventHandler<GlobalVariablesEventArgs> ValuesUpdated
}
Logo

UnderAutomation
66 Avenue des Champs-Elysées
75008 Paris
FRANCE

© 2021 UnderAutomation - UnderAutomation Universal Robots .NET Communication SDK (Software Development Kit)は、あらゆるURロボットと通信できる、カスタマイズされた.NET Core、.NET Framework、.NET Standardアプリケーションを作成する機能を提供します。Windows、Mac OS、Linux、LabView、Node.js、Python用のすぐに使えるサンプルが用意されています。TCP/IP Dashboard ServerとXML-RPCを使ってロボットをリモートコントロールし、Client Interfaceでデータストリームの受信とデコードを行います。