An expression is a formula that can be used to define a list of values for a motor or other device. All expressions have a name and can be constructed from values, variables, and/or constants that are manipulated by operators. For example,
In the above example, the expression calculates a set of positional values for motorB.softPosition that are twice the set of positional values for motorA.softPosition.
To break it down, motorB.softPosition is the expression name and represents both a node on the system (specifically, the motorB motor device’s software position node, motorB.softPosition) and a set of calculated values. As such, the motorB.softPosition name allows for the set of values to be applied to an actual node in NICE, motorB.softPosition, but also be applied elsewhere, such as in other expressions.
Continuing with the example, we see the formula motorA.softPosition * 2
Of note, motorA.softPosition is a variable because it is also an expression with a formulated value set that can be subject to change – so if motorA.softPosition’s values change, motorB.softPosition’s values will also change.
In its simplest form, an expression can be a single value.
In the above example, the expression calculates a set of positional values for motorB.softPosition with only one value, 16.0 – as such, motorB.softPosition will always be set to 16.0.
Values in an expression can also be received from a function (see Functions). The entirety of an expression might simply be calling a function that was created in Init – or it might be calling a function and then operating on the returned value with other values, variables, and/or constants.