25.2
Data types

Data types

Wandelscript supports a range of common and more robot-specific data types.

Primitives

Integer

n = 1

Integer value, abbreviated with int.

Float

f = 4.2

Floating point number, abbreviated with float.

String

s = "A string"

String value, represents text, abbreviated with str.

Boolean

b = True

Boolean value, either True or False, abbreviated with bool.

Frame

a = frame("a")

Coordinate system reference, can be used to transform poses from source to target coordinate system via the operator, abbreviated with frame. Can also be used to indicate the TCP to be used by referencing to the coordinate system of the TCP, e.g. flange = frame("Flange").

Position

position = (1, 2, 3)

Single point, defined in (x, y, z) with floating point numbers. Use . as a decimal separator.

Pose

pose = (1, 2, 3, 0.4, 0.5, 0.6)

Object's position and orientation, defined in (<position>, <orientation>). Learn how to use poses for path planning here.

TCP

tcp("<tcp_id>")

Tool Center Point, point where the end effector meets the work piece and which is used to define the robot's movements. TCPs are defined on the robot controller.

Either use the Robot Pad's dropdown menu to see which TCPs are available on the robot controller

TCP selection in Robot Pad

If the desired TCP is not listed in the available TCPs, the TCP must be added manually to the robot controller.

OR

Use Motion Group Infos > List TCPs GET /api/v1/cells/{cell}/motion-groups/{motion-group}/tcps.

{
  "tcps": [
    {
      "id": "Flange",
      "readable_name": "Default-Flange",
      "position": {
        "x": 0,
        "y": 0,
        "z": 0
      },
      "rotation": {
        "angles": [
          0,
          0,
          0,
          0
        ],
        "type": "ROTATION_VECTOR"
      }
    }
  ]
}

Setting a TCP can be done by referencing the TCP's ID, e.g. tcp("Flange"), or by referencing the respective coordinate system frame("Flange").

Array

arr = [1, 2, 3, 4, 5, 6]
val = arr[2]  # val == 3

Stores data types, accessed by arr[<index>]

Record

A record stores key-value pairs:

record = { <key>: <value>, ... }.

Records support nested key-value structure:

record = {
  k1: value1,
  k2: value2,
  k3: {
    k4: value4
  }
}

Access the record values with record.<key> and record["key"] for nested key-value pairs:

val_property_access = record.k1  # val_property_access == value1
val_key_access = record["k3"]  # val_key_access == { k4: value4 }

Records are immutable, so once a record is created, it cannot be changed further down the program by reassigning new key-value pairs. You can only change the existing record by using the builtin assoc method to assign new values based on the keys of the existing record.

record1 = { a: 1, b: 2 }
record2 = assoc(record1, "a", 3)  # record2 == { a: 3, b: 2 }

Example

Define a position.

a = (4, 5, 6, 1, 2, 3)
b = a
c = (7, 8, 9)
d = a :: c

Read pose components.

a_x = a[0]
a_rz = a[5]

Using negative indices.

a_rx = a[-3]

Read position/orientation vector components

c_y = c[1]

Setting pose/position/orientation components.

a_new_y = assoc(a, 1, 0)
c_new_z = assoc(c, 2, c[0])

Also using negative indices.

c_new_y = assoc(c, -2, 42)

Coordinate Systems

Coordinate systems are used to calculate movements from tools, the robot, in reference to the robot's base (world) (0, 0, 0, 0, 0, 0). Wandelscript supports creation and manipulation of coordinate systems as a first-class citizen. Coordinate systems are defined as a pose which transforms the source coordinate system to a target coordinate system.

  1. Reference to a coordinate system (frame) and assign it to a variable:
a = frame("a")
b = frame("b")
  1. Specify the transformation of the source coordinate system a to the target coordinate system b.
[a | b] = (0, 0, 10, 0, 0, 0)

In the example we define that b is relative to a with a translation of z = 10. With this syntax it is possible to build complex graphs of coordinate systems.

Furthermore it's possible to easily transform a pose into another coordinate system from the graph as shown in the following example.

g = 1
[a | b] = (0, 0, 10, 0, 0, 0)
[b | c] = (0, 5, 0, 0, 0, 0)
d = [c | a]

In this case the value of d will be a pose with (0, -5, -10, 0, 0, 0) and can be read as "what's the pose value of c in the coordinate system a ".

Getting the pose can be done via:

  • planned_pose that returns the robot pose for the program pointer
  • read(robot, 'pose') the actual pose of the robot