Skip to main content

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, simply press # inside the Expression Field, and a menu will pop up where you can select the desired Variable.
    You can just continue typing to filter the Variable list by Variable name. If you filter the Variables until there is only one left, you can also apply it by pressing Enter.
    The Variable will be displayed in its respective color, e.g. myVariable.

Expression Field

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'
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]