Skip to main content

List of variables

Variable naming rules

Variable names in the RL language can consist of letters, underscores, and numbers, but must start with a letter or underscore "_". However, variable names cannot be the same as system keywords. You can see Keywords pre-definition for RL system keywords.

In addition, there are precautions as follows:

In the same module, GLOBAL and LOCAL level variables with duplicated names are not allowed;

In different modules, GLOBAL variables with duplicated names are not allowed;

In different modules, LOCAL variables with duplicated names are allowed;

In the same module, no variables (GLOBAL, LOCAL, excluding ROUTINE) are allowed to have naming conflicts with functions in this module;

In different modules, no naming conflicts of GLOBAL level functions and variables are allowed;

When a variable name contains two characters only, it is important to note that the second character shall not be "h" or "b", otherwise, the variable may be converted to hexadecimal or binary. For more information, please refer to the Number system conversion.

Variable scope

The RL language system defines three scopes:

GLOBAL

It is visible to any program module of the current task, and can be declared in the module declaration area;

If variables need to be accessed across tasks, they shall be declared using the GLOBAL PERS keyword.

Attention: The variables in the variable list and point list are all global, and are readable and writable by all tasks.

LOCAL

It is only visible to the current program module, and can be declared in the module declaration area;

ROUTINE

It is only visible within the current function and can only be declared within the function body, and the scope type (GLOBAL or LOCAL) is not allowed to be specified when the scope variable is declared;

Attention: Scope only applies to variables, not custom functions.

Storage type

Each variable can be divided into three kinds: VAR (Variable), PERS (Persistent Variable), and CONST (Const Variable), depending on whether it can be modified during program execution.

VAR (Variable)

Variable, can be re-assigned in the process of program execution;

CONST (Const Variable)

Constant variable, cannot be re-assigned during program operation, and this type

must be determined at the beginning;

PERS (Persistent Variable)

Continuous variable. During program execution, if the value of the variable type changes,

the variable will be automatically modified from the initial value to the current value, thus achieving the effect of "Persistent" storage;

Note:

* Even if the value of a PERS type variable is changed while the program is running, the initial value displayed in the program editor declaration area is not immediately refreshed, and the initial value displayed in the program editor declaration area is updated to the latest value only when the program reloads or stops; * Regardless of whether the program is running or not, only the initial value of the PERS variable can be viewed in the "Variable Management" interface, and its current value can be viewed through status monitoring or the print command.

Keywords pre-definition

The following are reserved keywords (case insensitive) that are predefined for the RL language:

Module, EndModule, Proc, EndProc, Func, EndFunc, SetDO, DO_ALL,

SetGO, SetAO, WaitDI, Wait, WaitUntil, WaitWObj, WBID, Q, P, J, V, W, T, S, L, CA, DURA, IGNORELEFT, EJ, 1J, FCBV, FCCV, FCOL, FCXYZ, FCCART, PE, PER, TCP, ORI, EXJ, CFG, PDIS, JDIS, MoveAbsJ, MoveJ, MoveL, MoveC, MoveT, LOCAL, TASK, GLOBAL, VAR, CONST, PERS, INV, DOT, CROSS, sin, cos, tan, asin, cot, acos, atan, atan2, sinh, cosh, tanh, ln, log10, pow, exp, sqrt, ceil, floor, abs, rand, GetCurPos, Print, PrintToFile, ClkRead, TestAndSet, IF , Else, Endif, WHILE, ENDWHILE, for, from, to, endfor, Break, Continue, Del, Int, Double, Bool, String, BYTE, Robtarget, Speed, Zone, Tool, Wobj, Jointtarget, TriggData, Load, FCBoxVol, FCSphereVol, FCCylinderVol, FCXyzNum, FCCartNum, Pose, CLOCK, INTNUM, SYNCIDENT, TASKS, Call, Return, EXIT, Pause, StopMove, StartMove, StorePath, RestoPath, True, False, Interrupt, When, Offs, CalcJointT, CalcRobT, CRobT, RelTool, SocketCreate, SocketClose, SocketSendByte, SocketSendInt, SocketSendString, SocketReadString, SocketReadBit, SocketReadInt, SocketReadDouble, AccSet, MotionSup, TriggIO, TriggJ, TriggL, TriggC, On, Off, clock, intnum, userframe, pinf, ninf, FCFRAME_WORLD, FCFRAME_TOOL, FCFRAME_WOBJ, FCFRAME_PATH, FCPLANE_XY, FCPLANE_XZ, FCPLANE_YZ, FC_LINE_X, FC_LINE_Y, FC_LINE_Z, FC_ROT_X, FC_ROT_Y, FC_ROT_Z, Offs, CalcJoinT, CalcRobT, CRobT, RelTool, Start, Time, ClkReset, ClkStart, ClkStop, CONNECT, WITH, IDisable, IEnable, ISignalDI, Single, SingleSafe, WaitWobj, DropWobj, WobjIdentifier, WobjAngle, ActUnit, DeactUnit, INTNO, Exp, DoubleToStr, WaitSyncTask, FCAct, FCDeact, FCLoadID, FCCalib, FCSupvForce, FCSupvTorque, FCSupvPosBox, FCSupvPosSphere, FCSupvPosCylinder, FCSupvOrient, FCSupvOrient, FCSupvReoriSpeed, FCSupvTCPSpeed, FCCondForce, FCCondTorque, FCCondOrient, FCCondReoriSpeed, FCCondPosBox, FCCondPosCylinder, FCCondPosSphere, FCCondTCPSpeed, FCCondWaitWhile, FCRefLine, FCRefRot, FCRefSpiral, FCRefCircle, FCRefForce, FCRefTorque, FCRefStart, FCRefStop, FCSetSDPara

Number system conversion

The RL language supports direct entry of hexadecimal, binary, or values of scientific notation by adding a number system identifier after a number or letter.

Example 1

After the "h" suffix is added after 0−9, a−f, or A−F, the RL compiler treats the corresponding number or letter as hexadecimal and converts it to decimal in the compiler. For example:

8h stands for 8 in hexadecimal and 8 in decimal;

bh stands for b in hexadecimal and 11 in decimal;

25h stands for 25 in hexadecimal and 37 in decimal;

Example 2

After the "b" suffix is added after 0−9, a−f, and A−F, the RL compiler treats the corresponding number or letter as binary. For example:

1b stands for 1 in binary and 1 in decimal;

10b stands for 10 in binary and 2 in decimal;

1010b stands for 1010 in binary and 10 in decimal;

Example 3

Adding the "e±x" after a number indicates that the number is multiplied by 10 to the x power. For example:

5e+20 represents 5×10^20;

26e−15 represents 26×10^(−15);

112e−10 represents 112×10^(−10);

Variable declaration

A declaration must be made before using a variable. The format of the variable declaration command is as follows:

SCOPE STORAGE TYPE varname

Where:

1. SCOPE refers to variable scope. Please refer to Variable Scope;

2. STORAGE refers to variable storage type. Please refer to Storage Types;

3. TYPE refers to variable type, and can be a basic type or a special type. Please refer to Variable Type;

4. varname is the variable name. Please refer to Variable Naming Rules;

The content in square bracket is optional and can be either initialized or not when variables are declared. For variables that are not explicitly initialized when they are declared, the system automatically assigns different initial values as per the type of the variables. The default initial value may cause program execution problems in some cases, so it is recommended to initialize each manually added variable.

Example

There are a few examples of variable declarations as follows:

Example 1

VAR int counter = 8; //Declare the integer variable count and assign an initial value of 8

VAR double time = 2.5; //Declare floating-point variable time and assign an initial value of 2.5

VAR bool ifOpen = true; //Declare the variable bool type ifOpen and assign the initial value of true

Example 2

In general, no duplicate names are allowed for variables:

VAR int counter = 8;

VAR double counter = 2.5;

The compiler will report an error message at this time by prompting "Failed to add variable".

Example 3

However, a global variable and a local variable can have the same variable name:

VAR int counter = 1;

GLOBAL int counter = 555;

Although variables with different scopes allow duplicate names, it is not recommended to use variables with duplicate names in order to avoid confusion and misuse, unless the variables with duplicate names have special technological advantages.

Variables cannot be declared inside loop statement blocks such as while, otherwise, duplicate declarations will be caused when this part of the code is repeatedly executed, resulting in a "Fail to add variable" error. Please declare the variables outside the loop body.

Use restrictions

The ROUTINE variable that declares the PERS storage type is not supported;

When there is a duplicate name for variables or functions of different levels, the compiler will decide which variable to be used based on the priority of the scope. Variables with the highest priority order will be selected first, and those with lower priority order will be obscured and hidden. The priority of scopes is as follows:

  • When the variable names are duplicated, the priority of scopes is as follows: ROUTINE> LOCAL> GLOBAL;

  • When the function names are duplicated, the priority of scopes is as follows: LOCAL > GLOBAL;

User variable hold

The user variable "a" with hold is created in an RL project. This user variable is marked as a PERS variable, then the value of this variable is held on the non-volatile storage media when RL stops, the robot restarts, shuts down, or is powered off. When the robot is powered on again or RL is running again, the value of variable a is restored to the value held. The initial value is assigned only when the variable is created for the first time or re-edited. (Attention: Only PERS variables added to the variable list possess the hold attribute. However, PERS variables defined in the variable declaration area have no hold attribute.)

The persistence is supported for the following user variable types: Int, byte, double, bool, string, pose, speed, zone, fcboxvol, Fcspherevol, fccylindervol, fcxyznum, fccartnum, and torqueinfo.

When the user variable persistent configuration is on the RL project interface, the entries where persistent variables can be created as shown in the red boxes below:

image294

Click the variable list, point list, tool list, or work object list to create user variables of corresponding type. All variables for which the persistent attribute can be created have a "persistent" attribute item, where "yes" indicates that the variable is a persistent variable, marked as a PERS variable. For example, create a PERS variable of int type, whose configuration is as follows: (Other types can be configured by analogy)

image295

Modification of PERS variable

The PERS variables of the xCore control system are stored in the form of initial value+hold value.

The initial value refers to the data input by users to the variable list, and the hold value is the data, after it is modified by the program, stored on the non-volatile storage medium. The hold values of base types (int+bool+double) can be observed by status monitoring, and structure data (e.g., points, tools, work objects) can be printed by the print command.

During the operation of RL program, the PERS variable can be modified by the operator "=", and the modified data will be stored as a hold value within the controller. For the next time of program operation, the hold value of corresponding variable is preferred to be read, and if there is no hold value, the initial value of the variable is read.

If the PERS variable is modified by the point update button or the editing function of the variable list, the initial value and hold value are modified at the same time.

Variable list operation

The variable list interface allows the creating, viewing, modification, and deletion of almost all variables in the robot system. The currently supported variable types include:

S/N

Variable Type

Description

1

System predefined variables

Variables that cannot be modified by users and are used to store certain system parameters, such as tool0/wobj0.

2

User predefined variables

Variables that can be modified by users and used in multiple programs, such as user-calibrated tools and work objects.

3

Program variables

Variables defined by the user in the program, which are generally used only in the current program and its subprograms. Program variables include most of the variable types supported by the system.

Variable viewing

For some types of variables that have specifically defined steps, such as: speed/zone (defined and modified on the auxiliary programming interface). Although such variables can be viewed and modified in the Variable View interface, it is still recommended to use the dedicated interface for modification for the sake of convenient operation and fewer errors. The variable management interface should be used primarily for viewing operations.

image296

The variables that can be viewed and modified in the variable list interface are limited to those used in the currently loaded robot program. Therefore, the displayed variables will change when other programs are loaded.

Variable editing

If you need to add variables or modify certain existing variables, you can click the "New" or "Modify" button to enter the variable editing page for relevant operation.

Type

Used to select variable types when creating new variables. All supported types are listed in the sidebar on the left.

Name

Enter the variable name.

Dimension

To create or modify arrays, supporting up to 3D arrays.

Persistent

Define as a persistent (pers) variable or non-persistent variable

Value

Display the variable value

Description

Provide a description of the variable