Skip to main content
Version: v9

Expression Field

In an Expression Field, you can not just enter a number, but rather a mathematical Expression. The RobFlow convention for these Expressions matches the Python programming language.

Basic mathematical operations:

  • Plus: +
  • Minus: -
  • Multiply: *
  • Divide: /

Logical Operators:

  • AND: and
  • OR: or
  • Equal: ==
  • Not Equal: !=

Variables

  • To insert a Variable, type # (or {{) in the Expression field. A list of Variables opens at the cursor, each with its type — Integer, Float, Boolean, String, Cartesian Pose, Joint Pose, or Dynamic for Current Cartesian Pose and Current Joint Pose.
    Keep typing to filter it by name, move through it with ↑ and ↓, and press Enter (or click) to insert the highlighted Variable; Esc closes the list.
    The Variable then shows as a chip in its type's color, e.g. myVariable.

The ▶ button at the end of the field evaluates the Expression with the current Variable values and shows the result in a message, Expression evaluation value: …. The ℹ button opens this page. A field that names a Variable that no longer exists is marked invalid.

The Variable list that # opens in an Expression fieldThe Variable list that # opens in an Expression field

The config panel of a Loop Node with an Expression field for the iterationsThe config panel of a Loop Node with an Expression field for the iterations

JSON:

  • You can store JSON data inside a String Variable. This allows you to access structured or nested data directly inside Expressions.
  • To access values within the JSON, use bracket notation — similar to how you would access data in Python.
    Example: myVariable["key0"]["key1"] will access the nested value under key1 inside key0.
  • If the item is an array, you can also use numeric indices to access elements.
    Example: myVariable["users"][0]["name"] will return the name of the first element in the users array.

Extended mathematical functions (see Python Mathematical Functions for details):

  • 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'cbrt', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'erf', 'erfc', 'exp', 'exp2', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma', 'log', 'log1p', 'log10', 'log2', 'modf', 'pow', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc', 'prod', 'sumprod', 'perm', 'comb', 'nextafter', 'ulp', 'pi', 'e', 'tau', 'inf', 'nan'
note

Every name in Python's math module is available, so the list above reflects the module as it currently ships. The built-in functions below, by contrast, are a fixed allow-list.

Python built-in functions (see Python Built-In Functions for details):

  • 'min', 'max', 'abs', 'round', 'sum', 'len', 'all', 'any', 'int', 'float', 'str', 'bool'

The last four (int, float, str, bool) convert a value to another data type. For example, float("2.5") turns a number stored as text into the number 2.5, which you can then use in a numeric input field, such as the one of a Delay Node.

note

If you use number arrays, make sure to add whitespaces between the entries. Otherwise, numbers may be treated as float values (e.g. [1,2,3] will be evaluated to [1.2, 3]. Using [1, 2, 3] would work as intended. See examples below).

Pose Expressions:

Pose Expressions provide a structured way to represent positions and orientations. These Expressions can represent either Cartesian Poses or Joint Poses.

The syntax below is what a Pose Expression looks like written out. In the app you normally build one field by field in the Pose Expression Configurator instead — see Configure Pose Expression.

Cartesian Pose Expressions:

  • A Cartesian Pose Expression defines a 3D position and an orientation, optionally relative to a reference frame.
  • Format: [PositionX, PositionY, PositionZ, OrientationZ, OrientationY, OrientationX], ReferenceFrame
  • Example: [100+3, IntVar*FloatVar, PoseB.z, PoseA.rz, PoseA.ry, PoseA.rx], PoseD
  • Breakdown:
    • 100+3, IntVar*FloatVar, and PoseB.z: Define the X, Y, and Z position components.
    • PoseA.rz, PoseA.ry, PoseA.rx: Represents the orientation of the pose.
    • PoseD symbolizes the reference frame. Generally the reference frame can be BASE or you can specify a CartesianPoseVariable (in this example PoseD).

Joint Pose Expressions:

  • A Joint Pose Expression defines values for individual joints.
  • Format: [Joint1, Joint2, Joint3, ...]
  • Example: [JointPose.j1, IntVar, 100*2, 3+4, FloatVar, JointPoseB.j3]
  • Breakdown:
    • Each entry specifies a new value for the corresponding joint.
    • Example: JointPose.j1: References the current value of the first joint of the JointPoseVariable named JointPose.

Example Expressions:

  • 2 * 3 * 4 ==> 24
  • 2 * pi ==> 6.283
  • pow(2, 3) ==> 8
  • sqrt(9) ==> 3
  • 2 * True ==> 2
  • 2 * False ==> 0
  • 2 * myVariable ==> 4 (myVariable=2)
  • True or False ==> True
  • True and False ==> False
  • 3 != 3 ==> False
  • 5 == 5 ==> True
  • sum([1, 2, 3]) ==> 6
  • sum([1,2,3]) ==> 4.2 (evaluates to sum([1.2, 3]), see note above)
  • min([4, 7]) ==> 4
  • max([4, 7]) ==> 7
  • len([4, 7]) ==> 2
  • all([True, False]) ==> False
  • any([True, False]) ==> True
  • [100+3, IntVar*2, PoseB.z, PoseA.rz, PoseA.ry, PoseA.rx], BASE
  • [JointPose.j1, 90, FloatVar]