Skip to main content

基础变量和结构体

15.2 Basic variable and structure

All variable types supported by the RL command. The indivisible types, including int, double, bool, and string are basic variables (also known as primary variables), which are the foundation of all variable types. Combined by certain rules, the variable types are called structures.

15.2.1 Composition of structure

The combination rules for structures generally combine data with physical significance abstractly.

Example:

  • The structure pos combines three doubles into a position (xyz) in three-dimensional space.

  • The structure orient combines four doubles into a quaternion that describes the orientation.

  • The structure pose combines position (pos) and orientation (orient) into a pose parameter that describes the robot position.

15.2.2 Use of structure

Structures, serving as parameters for commands, can be performed in finer ways based on the scenarios. Its data can be modified directly via the specified RL commands.

Example 1:

Robtarget structure consists of: space position (pos), orientation (orient), configuration data (confdata), and external axes (double array). Their names are trans (pos), rot (orient), conf (confdata), extax (double), and users can access the structure members directly in the RL function via their names.

robtarget rob1 = …​ // variable list or user-customized Cartesian variable

rob1.trans.x + = 20 // add the x of point position to 20

// In the structure definition of trans (pos), it contains three variables of x, y, and z

// The x of the last visit to rob is therefore rob1.trans.x

print (rob1.trans) // print the position data only

Example 2:

The following is available for the wobj frame:

// Taking default wobj0 as an example

wobj0.robhold // work object handheld (bool).

wobj0.ufprog // user frame programmed (bool, rarely used).

wobj0.ufmec // user frame mechanical unit usually for plating lines and tracking (string).

wobj0.oframe // work object frame pose

wobj0.oframe.x // work object frame pose x

wobj0.oframe.y // work object frame pose y

wobj0.oframe.z // work object frame pose z

wobj0.q1 // work object frame pose quaternion

wobj0.uframe_id// work object-related user frame id

Other complex structures can also refer to this method for structure access.