Expressions Used by Flow Control

For flow control, conditions such as if-then-else, while-do, and do-while request Boolean expressions. A set of predefined functions is available. Each function works on specific types or a set of types.

This page discusses:

Global Functions and Instructions

The global functions and examples follow.

Operator Type Result
= Equality operator
A=B
Returns true if the values of A and B are equal.
Note: Always true if A and B are pure.
<> Inequality operator
A<>B
Returns true if the values of A and B differ.

Examples

IO_Double1 = 5
IO_Double1 = IO_Double2
IO_Double2 <> 5
IO_Double2 <> IO_Double2

Boolean Functions

The Boolean functions and examples follow.

Type Result
not
not A
Returns true if the value of A is true.
Returns false if the value of A is true.
and
A and B
Returns true if A and B are true.
Returns false otherwise.
or
A or B
Returns true if the value of A or the value of B are true.
Returns false otherwise.
xor A xor B : returns true if A and B have 2 distinct values, false otherwise

Examples

IO_Boolean
not IO_Boolean
not IO_Boolean1 and not IO_Boolean2
not (IO_Boolean1 and not IO_Boolean2)
IO_Boolean1 or IO_Boolean2

Orderable Class Functions

The orderable class functions and examples follow.

Type Result
<
A<B
Returns true if the value A is less than B.
>
A > B
Returns true if the value A is greater than B.
<=
A <= B
Returns true if the value A is less than or equal to B.
>=
A >= B
Returns true if the value A is greater than or equal to B.
max
max (x,y)
Returns x if x is greater than y.
min
min (x,y)
Returns x if x is less than y.

Examples

IO_Double1 > 5
IO_Double1 > 5 and IO_Double1 < 10 or IO_Boolean
min (5, IO_Double2) >= IO_Double1

Bitwise Functions

The biwise functions follow.

Type Result

A | B

lor (A, B)

Bitwise or

A & B

land (A, B)

Bitwise and

A ^^ B

lxor (A, B)

Bitwise xor

~A

lnot (A)

Bitwise not

A << N

lsl (A, N)

Left-shift by N bits

A >> N

lsr (A, N)

Right-shift by N bits

Numerical Functions: Class Number

The numerical functions for the class number and examples follow.

Type Result
+
Addition
x+y
-
Subtraction
x-y
*
Multiplication
x*y
/
Division
x/y
**
Raising to a power, or exponentiation
x**y
abs
absolute value of x
abs(x)

Examples

(IO_Double1 + IO_Double2) > 5
abs (IO_Double) = 5
(IO_Double1 ** IO_Double2) > 100

Mathematical Function: Class Integer

The mathematical function for the class integer follows.

Type Result

x % y

mod(x,y)

Returns the integer modulus of x/y, namely. x-floor(x/y)*y. Result and

arguments must have the type Real or Integer. If either of the arguments is Real the

The result is Real otherwise Integer.

Mathematical Functions: Class Floating

The mathematical functions for the class floating follows.

Type Result
sin(x) Sine of input in radian
cos(x) Cosine of input in radian
tan(x) Tangent of input in radian
asin(x) Principal arc sine in the interval [-pi/2, +pi/2]
acos(x) Principal arc cosine in the interval [0, pi]
atan(x) Principal arc tangent in the interval [-pi/2, +pi/2]
atan2(x,y) Principal arc tangent in the interval [-pi, +pi]
sinh(x) Hyperbolic sine of the input in radian
cosh (x) hyperbolic cosine
tanh (x) hyperbolic tangent
exp (x) exponential, base e
log (x) natural (base e) logarithm (x > 0)
log10 (x) base 10 logarithms (x > 0)
sqrt (x) Returns the square root of v if v>=0. Argument v needs to be an Integer or Real expression.
rand()

Returns a pseudo-random integer in the range between 0 and 32767

rand() % 100 returns a value in the range 0 to 99

String Function

The String function follows.

Type Result
A ++ B

Concatenate A and B after string conversion.

A and B can be String/Boolean/Integer/Double.

Type Conversion Functions

The Type Conversion functions follow.

Type Result
BooleanToNumber BooleanToNumber(x) : if true returns 1, otherwise returns 0
NumberToBoolean NumberToBoolean(x) : if zero returns false, otherwise returns true
DoubleToInteger DoubleToInteger(x) : discard the fractional part.
IntegerToDouble IntegerToDouble(x) : convert the integer value to the nearest real value that the destination floating-point type can represent.
ToString ToString(x) : Convert Boolean/Integer/Double or Position to a Unicode string.

Case Expressions

The Case expressions follow.

Type Result
e1, e2, e3

Record of expressions. The test expressions are going to be compared with recorded expressions.

Test(v)

case 1, 2, 3 : ….

n1 -> n2

Between operator. The test expression values must be between n1 & n2.

Test(v)

case 1 -> 3 : ….

=

Equality operator (Operator is optional).

Test(v)

case 1 : ….

case =2 :…

<>

Inequality operator.

Test(v)

case <>1 :….

>=

<=

>

<

Comparison operators.

Test(v)

case >1 : ….

case <= -5 :….

Position Functions

Position variables use "." operator syntax to access and call member functions. The Position functions and examples follow.

Data Members

Type Result Error Conditions
.type

Read/write position variable type

p1.type := "tag"

Tag also applies to tool and object frame variables. Use the tag to indicate a Cartesian position.

Invalid type set

Valid Entries : "tag"

.x, .y, .z

Read/write x, y, z Cartesian coordinates

p1.x := x

N/A

.w, .p, .r

Read/write w, p, r Cartesian coordinates

p1.w := x

N/A

.config

Read/write configuration values of an individual position

p1.config := x

config <= 0

config > max config available

.t1, .t2, …, .t10

Read/write turn the values of an individual position

p1.t1 := x

Turn is invalid for robot (not -1, or +1)

.refframe

Read/write reference frame Cartesian coordinates are relative to

p1.refframe := "pallet"

Robot origin and robot mount are valid values.

Object frame with a specified name does not exist

.redundant

Read/write 7DOF robot redundant angle

p1.redundant := x

N/A
.j

Read/write joint position values individually. For Tag position variables, the joint position array contains the aux axis values. The 1st aux axis value is at index 1. The system does not store the robot joint values.

p1.j[1] := x

p2.j := p1.j

Joint index > 32 set
.size

Read/write number of joint values in a position

x := p1.size

Setting this value can have unexpected results during simulation. Avoid setting this value.

N/A

Examples

<position> p1, p2
<string> x
x := p2.type
p1.type = x

<integer> config
config := p2.config
p1.config = config

<double> redundant
redundant := p2.redundant
p1.redundant = redundant

<integer> size
size := p2.size
p1.size = size

Properties

Type Result Error Conditions
.quaternion

Read/write quaternion representation of the rotation component

x := p1.quaternion

N/A

.translation

Read/write translation components of a tag position variable

p2 := p1.translation

N/A

.rotation

Read/write rotation components of a tag position variable

p1.rotation := p2

N/A

.config_turns

Read/write config and turn components of a tag position variable

p2.config_turns := p1

N/A

Examples

<position> p2
p2.quaternion := {0, 0.707, 0, 0.707}

Member Functions

Type Result Error Conditions
.abs

Returns absolute magnitude of vector component

x := p1.abs()

N/A

.inv

Returns inverse Cartesian position matrix

p2 := p1.inv()

N/A

Global Functions

Type Result Error Conditions
dot

Returns dot product of vector components

x := dot(p1,p2)

N/A

cross

Returns cross product of 3D vectors

p3 := cross(p1,p2)

N/A

toradian

Convert degrees to radians

p1.w := toradian(x)

N/A

todegree

Covert radians to degrees

x := todegree(p1.w)

N/A

currentjointpos

Returns a joint variable containing the current joint position of the resources in the motion group of the task

p1 := currentjointpos("Motion Group.2")

Motion group name does not exist

Do not specify a motion group name for the MCRS task.

getnumjoints

Returns the total number of joints in the motion group of a robot task

x := getnumjoints("Motion Group.2")

Motion group name does not exist

Motion group name is not specified for MCRS task

getnumrobotjoints Returns the total number of joints for the robot in the motion group of the task

x := getnumrobotjoints("Motion Group.2")

Motion group name does not exist

Motion group name is not specified for MCRS task

Motion group does not contain a robot

xyzwprtomatrix

Computes transform matrix from a Cartesian position

x := xyzwprtomatrix(p1)

N/A

matrixtoxyzwpr

Computes Cartesian position from transform matrix

x := matrixtoxyzwpr(p1)

The input matrix is singular

The input matrix is incorrect size

cartesian

Returns position with Cartesian position values set

p1 := Cartesian(0.1, 0.2, 0.3, 2.1, 1.9, 0.23)

N/A
ReadByString

Read variable from compute name

x := ReadByString("var", <double>) + 0.51

Variable types do not match

Examples

<position> p1
<double[4,4]> x
x = xyzwprtomatrix(p1)

<double[4,4]> x
<position> p1
p1 := matrixtoxyzwpr(x)

<position> p1, p2
<position> HOME_p1, HOME_p2
p1 := ReadByString("HOME_POS" ++ i, <position>) + 0.01
    
<position[3]> HOME_POS
p2 := ReadByString("HOME_POS", <position>, {i}) + 0.01
    
<position[3]> home_pos_copy
home_pos_copy := ReadByString("HOME_POS", <position[3]>

Other Functions

Other functions and an example follow.

Type Result
if expr1 then expr2 else expr3 If expr1 is true, it returns expr2. Otherwise, returns expr3

Example

if (IO_Double1 + IO_Double2 < 40) then true else false