Rainbow Robotics - UI Script Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 88

RB UI Script 3.

7
(Date : 2021/07/31)
(Compatible up to version RB software 3.7.x)
[ENG]

Rainbow-Robotics
www.rainbow-robotics.com
Index

1. Variable Types and Declaration.......................................................................................................... 3


2. Math Functions ................................................................................................................................. 10
3. String Functions ................................................................................................................................ 18
4. Bit Functions ..................................................................................................................................... 22
5. System Functions .............................................................................................................................. 24
6. System Variables .............................................................................................................................. 46
7. Movement Functions ........................................................................................................................ 54
8. Grippers and Sensors ........................................................................................................................ 69
9. Communication Functions ................................................................................................................ 79
10. Vector.............................................................................................................................................. 86

Rainbow Robotics Inc. owns copyright and intellectual property rights on all contents and designs of this
manual. Therefore, the use, replication, and distribution of Rainbow Robotics Inc. properties and materials
without prior written permission is strictly prohibited and corresponds to Rainbow Robotics' infringement of
intellectual property rights.

User is solely responsible for any misuse or alteration of the patent rights of this equipment. The information
contained in this manual is reliable.

The information provided in this manual is the property of Rainbow Robotics Inc. and may not be reproduced
in whole or in part without of Rainbow Robotics Inc.’s consent. The information contained in this manual is
subject to change without notice.
For more information on revising the manual, please visit the website
(www.rainbow-robotics.com).

ⓒ Rainbow Robotics Inc. All rights reserved

2
1. VARIABLE TYPES AND DECLARATION

The UI Script of Rainbow Robotics supports the following data types.


 var : Stores a single number.
 arr : Stores the multiple number array. (up to 20 lengths)
 str : Stores string element.
 point, pnt : Stores posture (x, y, z, Rx, Ry, Rz) information.
 joint, jnt : Stores joint angles (J0, J1, J2, J3, J4, J5).
 vec : A vector that manages numbers.
(Please refer to Chapter 10 separately for number / string vectors.)

An example of a variable declaration is shown below.

var
Example :
var my_val # Assign variable without initial value (initial value is 0)
var my_val = 1 # Assign variable with initial value

arr
Example :
arr my_arr # Assign array without initial value (initial value is {0, 0, … , 0})
arr my_arr = {1, 2, 3} # Assign array with initial value

str
Example :
str my_str # Assign string without initial value (initial value is “”)
str my_str = “Hello” # Assign string with initial value

3
point, pnt
Example :
point my_point # Assign point without initial value (initial value is {0, 0, 0, 0, 0, 0})
point my_point = {100, 200, 300, 90, 0, 90} #Assign point with initial value
pnt my_point = {50, 100, 100, 90, 0, 0} #Assign point with initial value

joint, jnt
Example :
joint my_joint #Assign joint without initial value (initial value is {0, 0, 0, 0, 0, 0})
joint my_joint = {0, 0, 0, 90, 0, 0} #Assign joint with initial value
jnt my_joint = {30,0,0,90,0,0} #Assign joint with initial value

Abbreviations used in this document are as follows.

Abbreviation
v variable type (var)

a Array type (arr)

s String type (str)

P Point type (pnt)

J Joint type (jnt)

4
Point type and Joint type variables can be used as temporary variables without names.

 Temporary Point type : pnt[x, y, z, Rx, Ry, Rz]


 Temporary Joint type : jnt[J0, J1, J2, J3, J4, J5]

These temporary variables can be used immediately without a separate name declaration, and can be
utilized as follows.

Method 1) This is an example of declaring a separate variable and using it in a function.


Method 2) This is an example of using the temporary variable as a function call argument without
declaring a variable separately.

Method 1)
#Assign joint type with name ‘my_angle’.
jnt my_angle = {0,0,90,0,90,0}
#Use ‘my_angle’ as an input argument of function ‘move_j’.
move_j(my_angle, 60, 80)

#Assign point type with name ‘my_point’.


pnt my_point = {100, 200, 300, 90, 0, 0}
#Use ‘my_point’ as an input argument of function ‘move_l’
move_l(my_point, 20, 5)

Method 2)
#temporary joint type is used as an input argument of function ‘move_j’.
move_j(jnt[0,0,90,0,90,0], 60, 80)

#temporary point type is used as an input argument of function ‘move_l’.


move_l(pnt[100,200,300,90,0,0], 60, 80)

The above examples are examples using move_j(J, v, v) and move_l(P, v, v) functions.
For more information about these functions, see Chapter 7. Motion Functions.

5
Rainbow UI Script can be used as follows:

Example 1) Simple math operation


var a = 1 # Assign variable, name is ‘a’ and init-value 1
var b = 2 # Assign variable, name is ‘b’ and init-value 2
var c # Assign variable, name is ‘c’
c = a *b + 5 + sqrt(4) # ‘c’ stores the result value of 9

Example 2) Basic movement


joint target_angle = {0, 0, 90, 0, 90, 0} #Assign joint type, name is ‘target_angle’
move_j(target_angle, 60, 80) #move arm with ‘move_j’, speed/acceleration = 60/80
target_angle[0] = target_angle[0] + 45 #Add 45 degrees to the axis-0 value from the
previous value.
move_j(target_angle, 30, 40) #move arm with ‘move_j’, speed/acceleration = 30/40
target_angle[0] = target_angle[0] +45 #Add 45 degrees to the axis-0 value from the
previous value.
move_j(target_angle, 60, 80) #move arm with ‘move_j’, speed/acceleration = 60/80
move_j(jnt[0, 0, 0, 0, 0, 0], 60, 80) #move arm with ‘move_j’ to zero-home posture

Example 3) String function


str my_text = “123.78” #Assign string with name ‘my_text’
var result_1 = to_num_int(my_text) #123 is stored in variable ‘result_1’
var result_2 = to_num(my_text) #123.78 is stored in variable ‘result_2’
var result_3 = round( to_num(my_text) ) #124 is stored in variable ‘result_3’
str my_text2 = “abc” #Assign string with name ‘my_text2’
str my_text3 = my_text + my_text2 #“123.78abc” is stored in string ‘my_text3’

6
The following comparison operators and logical operators can be used.

[Comparison operators]

A >= B
# 1 (True) if the left side is greater than or equal to the right side, otherwise 0 (False)

A <= B
# 1 (True) if the right side is greater than or equal to the left side, otherwise 0 (False)

A == B
# 1 (True) if the left and right sides are equal, otherwise 0 (False)

A != B
# 1 (True) if the left and right sides are not-equal, otherwise 0 (False)

[Logical operators]

A && B
A and B
A AND B
A And B
# 1 (True) only if both the left and right sides are True, otherwise 0 (False)

A || B
A or B
A OR B
A Or B
# 1 (True) if either of the left and right sides is True, 0 (False) if both values are False

7
TRUE and FALSE used in comparison/logical operation are matched with the following values.

: True = TRUE = true = 1


: False = FALSE = false = 0

Therefore, the following two examples become the same expression.

Example 1)
if (SD_SOCK_IS_OPEN_0 == True){
~~
}
Example 2)
if (SD_SOCK_IS_OPEN_0 == 1){
~~
}

8
■ The Script grammar of Rainbow Robotics uses the following units.
> Angle : Degree
> Position : mm (0.001m)

■ The following rotation notation is used in the script grammar and notation of Rainbow Robotics.
> Z-Y’-X’’ Euler angle (Degree)

9
2. MATH FUNCTIONS

v = cos(v)

Trigonometric function Cosine operation function.


Input :
Single variable type or constant number
v: variable type or number (Unit: radian)

Return :
v : return single number

Example :
var my_result = cos(45*D2R) #my_result = 0.7071

v = cosd(v)

Trigonometric function Cosine operation function.


Input :
Single variable type or constant number
v: variable type or number (Unit: degree)

Return :
v: return single number

Example :
var my_result = cosd(45) #my_result= 0.7071

v = sin(v)

Trigonometric function Sine operation function.


Input :
Single variable type or constant number
v: variable type or number (Unit: radian)

Return :
v: return single number

Example :
var my_result = sin(30*D2R) #my_result= 0.5

10
v : sind(v)

Trigonometric function Sine operation function.


Input :
Single variable type or constant number
v: variable type or number (Unit: degree)

Return :
v: return single number

Example :
var my_result = sind(30) #my_result=0.5

v = tan(v)

Trigonometric function Tangent operation function.


Input :
Single variable type or constant number
v: variable type or number (Unit: radian)

Return :
v: return single number

Example :
var my_result = tan(45*D2R) #my_result=1

v = tand(v)

Trigonometric function Tangent operation function.


Input :
Single variable type or constant number
v: variable type or number (Unit: degree)

Return :
v: return single number

Example :
var my_result = tand(45) #my_result=1

11
v = acos(v)

Trigonometric function Inverse-Cosine operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number (Unit: radian)

Example :
var my_result = acos(-1) #my_result= PI (3.141592)

v = acosd(v)

Trigonometric function Inverse-Cosine operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number (Unit: degree)

Example :
var my_result = acosd(-1) #my_result=180

v = asin(v)

Trigonometric function Inverse-Sine operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number (Unit: radian)

Example :
var my_result = asin(1) #my_result= 1.5708

12
v = asind(v)

Trigonometric function Inverse-Sine operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number (Unit: degree)

Example :
var my_result = asind(1) #my_result= 90

v = atan(v)

Trigonometric function Inverse-Tangent operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number (Unit: radian)

Example :
var my_result = atan(1) #my_result= 0.7854

v = atand(v)

Trigonometric function Inverse-Tangent operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number (Unit: degree)

Example :
var my_result = atand(1) #my_result= 45

13
v = atan2(v, v)

Inverse trigonometric function that calculates the quadrant arc tangent.


Input :
Two variable types or constant numbers
v: y direction variable type or number
v: x direction variable type or number

Return :
v: return single number (Unit: radian)

Example :
var my_result = atan2(1, 1) #my_result= 0.7854

v = atan2d(v, v)

Inverse trigonometric function that calculates the quadrant arc tangent.


Input :
Two variable types or constant numbers
v: y direction variable type or number
v: x direction variable type or number

Return :
v: return single number (Unit: degree)

Example :
var my_result = atan2d(1, 1) #my_result= 45

PI

It is a constant representing the circumference (π).


Example :
var my_val = PI #my_val = 3.142

R2D

Operation constant (180/PI) to convert from radian to degree.


Example :
var my_ val= PI*R2D #my_val=180

D2R

Operation constant (PI/180) for converting degree to radian.


Example :
var my_val = 180*D2R #my_val=3.142

14
v = abs(v)

Calculate absolute value of input argument


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number

Example :
var my_result = abs(-5.2) #my_result= 5.2

v = sqrt(v)

Square root operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number

Example :
var my_result = sqrt (4) #my_result= 2

v = cell(v)

Rounding-up operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number

Example :
var my_result = cell(4.2) #my_result= 5

15
v = floor(v)

Rounding-down operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number

Example :
var my_result = floor(4.8) #my_result= 4

v = round(v)

Rounding operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number

Example :
var my_result = round(4.2) #my_result= 4
var my_result = round (4.8) #my_result= 5

v = log(v)

Natural logarithm (ln) operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number

Example :

var my_result = log(4) #my_result= 1.3862

16
v = log10(v)

Logarithm (log10 ) operation function.


Input :
Single variable type or constant number
v: variable type or number

Return :
v: return single number

Example :
var my_result = log10 (3) #my_result= 0.4771

v = pow(v, v)

Power operation function.


Input :
Two variable types or constant numbers
v: variable or constant that is a base of a power
v: variable or constant that is an exponent of a power

Return :
v: return single number

Example :
var my_result = pow(2,3) #my_result= 8

v = rand()

Random number generator function with a uniform distribution between 0 and 1..
Input :
None.

Return :
v: return single number

Example :
var my_result = rand() #my_result= 0.1315
var my_result = rand() #my_result= 0.7869
var my_result = rand() #my_result= 0.4277

17
3. STRING FUNCTIONS

v = str_empty(s)

This function returns the presence or absence of data in a string.


Input :
Single string type variable or constant string.
s: string type variable or constant string

Return :
v: return single number 0 or 1 (if string is empty 1, if it is not empty 0)

Example :
string my_str1 = “rainbow”
string my_str2

var my_result1 = str_empty(my_str1) #my_result1=0


var my_result2 = str_empty(my_str2) #my_result2=1

v = str_find(s, s)

A function that returns the index of a string's position within another string.
Input :
Two string type variables or constant strings.
s: reference string
s: string to find (target)

Return :
v: Returns a single number corresponding to the index.
: If it does not exist, it returns -1.

Example :
string my_str1 = “rainbow_robotics”
string my_str2 = “robotics”

var my_result = str_find(my_str1, my_str2) #my_result= 8


var my_result2 = str_find(my_str1, “world”) #my_result=-1

18
v = str_len (s)

A function that returns the length of a string.


Input :
Single string type variable or constant string.
s: string type variable or constant string

Return :
v: return single number (length of the string)

Example :
string my_str = “rainbow_robotics”
var my_result = str_len(my_str) #my_result=16

s = str_sub (s, v, v)

A function that truncates a string and returns part of it.


Input :
Single string type variable or constant string, and two variable types.
s: reference string
v: starting index for truncation (variable type or number)
v: length for truncation (variable type or number)

Return :
s: return truncated string

Example :
string my_str = “rainbow_robotics”
string my_result = str_sub(my_str, 3, 7) #my_result= “nbow_ro”

s = str_cat (s, s)

A function that concatenates strings together.


Input :
Two string type variables or constant strings.
s: First string
s: Second string

Return :
s: return added string

Example :
string my_str1 = “hi”
string my_str2 = “rainbow”

string my_res = str_cat(my_str1, my_str2) #my_res= “hirainbow”


string my_res2 = my_str1 + my_str2 #’+’ operator returns same result
string my_res3 = “My name” + “ is “ + “RB!” #my_res3=”My name is RB!”

19
v = str_cmp (s, s)

A function that compares strings with each other.


Input :
Two string type variables or constant strings.
s: single string for reference
s: single string for comparing target

Return :
v: Returns 0 if the strings are equal, or a single non-zero number if they are different.
If the strings are not equal, compares the first unequal character and returns a single number with a value greater
than zero if the base string is greater than the comparison string and less than zero if the string is less than.

Example :
string my_str1 = “hello”
string my_str2 = “hello”
string my_str3 = “hgello”
string my_str4 = “Hello”

#my_result1=0
var my_result1 = str_cmp(my_str1, my_str2)

#my_result2= -2 … compare e(101) and g(103)


var my_result2 = str_cmp(my_str2, my_str3)

#my_result3=2 ... compare g(103) and e(101)


var my_result3 = str_cmp(my_str3, my_str2)

#my_result4=32 … compare h(104) and (72)


var my_result4 = str_cmp(my_str1, my_str4)

v = to_num (s)

Convert character (string) numbers to real-number


Input :
Single string type variable or constant string.
s: string type variable or constant string

Return :
v: return single number

Example :
str my_string = “123.45”
var my_result = to_num(my_string) #my_result=123.45

20
s = to_str (v)
s = to_str (P)
s = to_str (J)

Convert variable/point/joint types to string type expression


Input :
Single variable type or point type or joint type
v/P/J: variable type or number or point type or joint type

Return :
s: return string

Example :
var my_value = 123.45
str my_result = to_str(my_value) #my_result= “123.45”

point my_point = {100,200,300,90,0,0}


str my_result = to_str(my_point) #my_result=“{100,200,300,90,0,0}”

joint my_joint = {90,0,0,90,0,0}


str my_result = to_str(my_joint) #my_result= “{90,0,0,90,0,0}”

s = to_str_int (v)

Converts a single number to a string of integers.


Input :
Single string type variable or constant string.
s: string type variable or constant string

Return :
s: return string

Example :
var my_value = 123.45
str my_result = to_str_int(my_value) #my_result= “123”

21
4. BIT FUNCTIONS

v = get_bit(v, v)

A function that obtains the bit of a specific bit position from a variable or constant.
Input :
Two variable types or constant numbers.
v: Target variable or number for the bit aquisition
v: Target bit index (position). Bit index is starting from 0.

Return :
v: Bit value ( 0 or 1)

Example :
var my_bit = get_bit(1234, 3)
#1234 = 0b10011010010
#my_bit=0

set_bit(v, v)

This is a function that changes the bit at a specific bit position in variable to 1.
Input :
Two variable types or constant numbers.
v: Target variable or number for the bit set
v: Target bit index (position). Bit index is starting from 0.

Return :
None.

Example :
var my_var = 1234
#1234 = 0b10011010010

set_bit(my_var, 3)
#my_var =1242

22
clear_bit(v, v)

This is a function that changes the bit at a specific bit position in variable to 0.
Input :
Two variable types or constant numbers.
v: Target variable or number for the bit clear
v: Target bit index (position). Bit index is starting from 0

Return :
None.

Example :
var my_var = 1234
#1234 = 0b10011010010

clear_bit(my_var, 1)
#my_var =1232

<<
>>
&
|

Bit shift operators, Bit and / or operators


Can use when bit-shifting or bit and/or operation

Example :
Var my_num = 12 #my_num = 0b1100
Var my_num2 = my_num << 2 #my_num2 = 48 (=0b110000)

23
5. SYSTEM FUNCTIONS

halt

Stop any program flow or action/movement.


Input :
None.

Return :
None.

Example :
halt

24
v = pattern_get_count(v)

A function to obtain the current index of the grid that is being performed by the pattern function.
Input :
Single variable type or constant number
v: Pattern number (Confirmation of assigned number is required.)
: The pattern unique number is set in the pattern action.

Return :
v: Returns the current index of the grid.

Example :
#Get the current grid index of pattern number 6691.
var current_count = pattern_get_count(6691)

pattern_set_count(v, v)

A function that forcibly sets the index of the grid that does the work in the pattern function.
Input :
Two variables types or constant numbers
v: Pattern number (Confirmation of assigned number is required.)
: The pattern unique number is set in the pattern action.
v: Desired grid index
: If the pattern is a 2D flat pattern, and there are grid points of 3x5 = 15, the configurable indices are 0 to 14.

Return :
None.

Example :
#Set the grid index of pattern number 6691 to 3.
pattern_set_count(6691, 3)

25
P = calc_fk_tcp(v, v, v, v, v, v)
P = calc_fk_tcp(J)

Calculate TCP posture w.r.t. global (base) coordinate from six joint angles.
Input type 1:
Six variable types or constant numbers.
v, v, v, v, v, v: six joint angles (Unit: Degree)

Input type 2:
J: Single joint type variable which contains six joint-angles.

Return :
P: Point type variable which contains TCP posture w.r.t. global (base) coordinate

Example :
# {0, -207.62,1100.59,0,0,0}will be return to ‘my_result’
# Depending on the TCP setting or robot model, the result may be different.
joint my_joint = {0,0,0,0,0,0}
point my_result = calc_fk_tcp(my_joint)

#Same result will be return to ‘my_result’


point my_result = calc_fk_tcp(0,0,0,0,0,0)

P = calc_fk_tfc(v, v, v, v, v, v)
P = calc_fk_tfc(J)

Calculate TFC (Tool Flange Center) posture w.r.t. global (base) coordinate from six joint angles.
※ The tool flange is where the gripper/tool is mounted on the robot.
Input type 1:
Six variable types or constant numbers.
v, v, v, v, v, v: six joint angles (Unit: Degree)

Input type 2:
J: Single joint type variable which contains six joint-angles.

Return :
P: Point type variable which contains TFC posture w.r.t. global (base) coordinate

Example :
# {0, -207.62,1100.59,0,0,0}will be return to ‘my_result’
joint my_joint = {0,0,0,0,0,0}
point my_result = calc_fk_tfc(my_joint)

#Same result will be return to ‘my_result’


point my_result = calc_fk_tfc(0,0,0,0,0,0)

26
v = point_dist(P, P)

Calculates the distance between two points.


Input :
Two Point type variables.
P: Target point 1
P: Target point 2

Return :
v: return single number (distance).

Example :
point my_ptr1 = {100, 200, 300, 0, 0, 0}
point my_ptr2 = {100, 200, 200, 0, 0, 0}

var my_result = point_dist(my_ptr1, my_ptr2)


# my_result = 100

P = point_add(P, P)

Calculates the addition of two points.


Input :
Two Point type variables.
P: Target point 1
P: Target point 2

Return :
P: Returns point, which is the result of adding two points.

Example :
point my_ptr1 = {100, 0, 300, 150, 0, 30}
point my_ptr2 = {100, 200, 300, 90, 0, 90}

point my_result = point_add(my_ptr1, my_ptr2)


# my_result= {200, 200, 600, -90, -30, -60}
# x,y,z Distance values are treated as simple arithmetic operations.
# Rx,Ry,Rz Rotation values are treated as rotation matrix operations.

27
P = point_sub(P, P)

Calculates the subtraction of two points.


Input :
Two Point type variables.
P: Target point 1
P: Target point 2

Return :
P: Returns point, which is the result of subtraction of two points.

Example :
point my_ptr1 = {100, 0, 300, 150, 0, 30}
point my_ptr2 = {100, 200, 300, 90, 0, 90}

point my_result = point_sub(my_ptr1, my_ptr2)


# my_result= {0, -200, 0, 0, 60, -60}
# x,y,z Distance values are treated as simple arithmetic operations.
# Rx,Ry,Rz Rotation values are treated as rotation matrix operations.

P = point_mid(P, P)

Calculates the midpoint between two points.


Input :
Two Point type variables.
P: Target point 1
P: Target point 2

Return :
P: Returns the point that is the midpoint between two points.

Example :
point my_ptr1 = {100, 0, 300, 150, 0, 30}
point my_ptr2 = {100, 200, 300, 90, 0, 90}

point my_result = point_mid(my_ptr1, my_ptr2)


# my_result= {100, 100, 300, 120, -8.21, 60}
# x,y,z Distance values are treated as simple arithmetic operations.
# Rx,Ry,Rz Rotation values are treated as rotation matrix operations.

28
P = point_interpolate(P, P, v)

Computes the interpolation point between two points.


Input :
Two Point type variables and single variable/number are required
P: Target point 1
P: Target point 2
v: Weight factor for interpolation (0~1)

Return :
P: Returns a point that is the result of interpolation between two points.

Example :
point my_ptr1 = {100, 0, 300, 150, 0, 30}
point my_ptr2 = {100, 200, 300, 90, 0, 90}

point my_result = point_mid(my_ptr1, my_ptr2, 0.1)


# my_result= {100, 20, 300, 144.43, -2.86, 35.37}
# x,y,z Distance values are treated as simple arithmetic operations.
# Rx,Ry,Rz Rotation values are treated as rotation matrix operations.

P = point_trans_g2u(P, v)

Converts the attitude value stored in the Point variable from the global (base) coordinate system to the user
coordinate system.
Input :
Single Point type variable and single number.
P: Target point
v: User coordinate number (User coordinate: 0, 1, 2)

Return :
P: Returns the converted point coordinate value.

Example :
point my_global_p
point my_local_p = point_trans_g2u(my_global_p, 0)

29
P = point_trans_u2g(P, v)

Converts the attitude value stored in the Point variable from the user coordinate system to the global (base)
coordinate system.
Input :
Single Point type variable and single number.
P: Target point
v: User coordinate number (User coordinate: 0, 1, 2)

Return :
P: Returns the converted point coordinate value.

Example :
point my_local_p
point my_global_p = point_trans_u2g(my_local_p, 0)

P = get_tcp_info()

This function returns the TCP information of the current robot.


Input :
None.

Return :
P: Returns the TCP of the current robot based on the global coordinate system. (Unit: mm & degree)

Example :
# TCP posture information will be stored in ‘my_result’
point my_result = get_tcp_info()

P = get_tfc_info()

This function returns the TFC (Tool flange center) information of the current robot.
Input :
None.

Return :
P: Returns the TFC of the current robot based on the global coordinate system. (Unit: mm & degree)

Example :
# TFC posture information will be stored in ‘my_result’
point my_result = get_tfc_info()

30
J = joint_add(J, J)

Calculates the addition of the angles of two Joints.


Two Joint type variables
J: Target joint 1
J: Target joint 2

Return :
J: Returns the joint, which is the result of the addition operation of two joints.

Example :
joint my_joint1 = {45, 15, 0, 0, 0, 90}
joint my_joint2 = {0, 45, 45, 15, 0, 0}

joint my_result = joint_add(my_joint1, my_joint2)


# my_result= {45,60,45,15,0,90}

J = joint_sub(J, J)

This function calculates the subtraction of two joint angles.


Two Joint type variables
J: Target joint 1
J: Target joint 2

Return :
J: Returns the joint, which is the result of the subtraction operation of two joints.

Example :
joint my_joint1 = {45, 15, 0, 0, 0, 90}
joint my_joint2 = {0, 45, 45, 15, 0, 0}

joint my_result = joint_sub(my_joint1, my_joint2)


# my_result= {45,-30,-45,-15,0,90}

31
J = joint_mid(J, J)

Computes the intermediate joint between two joint angles.


Two Joint type variables
J: Target joint 1
J: Target joint 2

Return :
J: Returns the joint that is the result of the intermediate joint operation of two joints.

Example :
joint my_joint1 = {45, 15, 0, 15, 0, 90}
joint my_joint2 = {45, 15, 0, 15, 0, 0}

joint my_result = joint_mid(my_joint1, my_joint2)


# my_result= {45, 15, 0, 15, 0, 45}

J = joint_interpolate(J, J, v)

Computes the interpolation joint between two joint angles.


Input :
Two Joint type variables and single variable/number are required
P: Target point 1
P: Target point 2
v: Weight factor for interpolation (0~1)

Return :
P: Returns a joint that is the result of interpolation between two joints.

Example :
joint my_joint1 = {45, 15, 0, 15, 0, 90}
joint my_joint2 = {45, 15, 0, 15, 0, 0}

joint my_result = joint_mid(my_joint1, my_joint2, 0.1)


# my_result= {45, 15, 0, 15, 0, 81}

32
J = get_joint_info()

Returns the current joint angle information.


Input :
None.

Return :
J: It returns the joint information of the current robot based on the joint coordinate system. (Unit: degree)

Example :
joint my_result = get_joint_info()
#current robot’s joint angles will be return to ‘my_result’

33
set_payload_info(v, v, v, v)

Set the tool payload w.r.t. the manufacturer’s default tool coordinate system.

※ The value set in this function returns to the default value after the program ends.
※ If this function is not called in program-flow, the value set in the Setup page is used.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Four variable types or constant numbers.
v: payload weight (Unit: kg)
v: payload Center of mass x-axis value (Unit: mm)
v: payload Center of mass y-axis value (Unit: mm)
v: payload Center of mass z-axis value (Unit: mm)
# Three values entered are based on the manufacturer's default tool coordinate system.

Return :
None.

Example :
# Set payload as 3kg, and center-of-mass as (0mm,-50mm, 0mm).
set_payload_info(3, 0, -50, 0)

set_tcp_info(v, v, v, v, v, v)

Set the TCP position and orientation w.r.t. the manufacturer’s default tool coordinate system.

※ The value set in this function returns to the default value after the program ends.
※ If this function is not called in program-flow, the value set in the Setup page is used.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Six variable types or constant numbers.
v: TCP’s x-value (Unit: mm)
v: TCP’s y-value (Unit: mm)
v: TCP’s z-value (Unit: mm)
v: TCP’s Rx value (Unit: degree)
v: TCP’s Ry value (Unit: degree)
v: TCP’s Rz value (Unit: degree)
# Six values entered are based on the manufacturer's default tool coordinate system.

Return :
None.

Example :
# Set TCP position as (0mm,-100mm, 0mm).
set_tcp_info(0, -100, 0, 0, 0, 0)

34
set_collision_onoff(v)

This function turns on/off the collision detection function.

※ The value set in this function returns to the default value after the program ends.
※ If this function is not called in program-flow, the value set in the Setup page is used.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Single variable type or constant number.
v: 0 is off , 1 is on

Return :
None.

Example :
#Turn on the collision detection function.
set_collision_onoff(1)

set_collision_th(v)

Sets the collision sensitivity (threshold).

※ The value set in this function returns to the default value after the program ends.
※ If this function is not called in program-flow, the value set in the Setup page is used.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Single variable type or constant number.
v: Value between 0 ~ 1. The lower the value, the more sensitive to collision. (0~1)

Return :
None.

Example :
#Set the collision threshold as 10%.
set_collision_th(0.1)

35
set_collision_mode(v)

Set the stop-mode after the collision detection.

※ The value set in this function returns to the default value after the program ends.
※ If this function is not called in program-flow, the value set in the Setup page is used.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Single variable type or the constant number.
v: Stop mode
0 = General Stop
1 = Evasion Stop

Return :
None.

Example :
# After detecting a collision, the robot moves a little in the direction to avoid external force and then stops the
movement.
set_collision_mode(1)

set_collision_after(v)

Set the program flow direction after the collision detection.

※ The value set in this function returns to the default value after the program ends.
※ If this function is not called in program-flow, the value set in the Setup page is used.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Single variable type or the constant number.
v: Stop mode
0 = Pause the Program flow (default)
1 = Halt/Stop the Program flow

Return :
None.

Example :
# After detecting an external collision, the program flow stops (ends).
set_collision_after(1)

36
set_speed_multiply(v)

Sets the overall speed (velocity) multiplier.

※ The value set in this function returns to the default value after the program ends.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Single variable type or the constant number.
v: Multiply value (0 ~2) (default: 1)

Return :
None.

Example :
var speed_override = 1.5
#Desired-speed = 1.5 x original-speed
set_speed_multiply(speed_override)

set_acc_multiply(v)

Sets the overall acceleration multiplier.

※ The value set in this function returns to the default value after the program ends.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Single variable type or the constant number.
v: Multiply value (0 ~2) (default: 1)

Return :
None.

Example :
var acc_override = 0.5
#Desired-acceleration = 0.5 x original-acceleration
set_acc_multiply(acc_override)

37
set_speed_acc_j(v, v)

Sets fixed joint velocity/acceleration for J-series motions (MoveJ, MoveJB, MoveJL).

※ The value set in this function returns to the default value after the program ends.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Two variable types or constant numbers.
v: Speed/ Velocity (Unit: 𝒅𝒆𝒈/𝒔)
Does not lock the speed for negative input.
v: Acceleration (Unit: 𝒅𝒆𝒈/𝒔𝟐)
Does not lock the acceleration for negative input.
Return :
None.

Example :
# Ignoring the speed/acceleration set for each point of Move,
#set speed as 10 𝑑𝑒𝑔/𝑠, and acceleration as 3 𝑑𝑒𝑔/𝑠 2 .
set_speed_acc_j(10, 3)

# Ignoring the acceleration set for each point of Move,


#set acceleration as 5𝑑𝑒𝑔/𝑠 2 .
set_speed_acc_j(-1, 5)

set_speed_acc_l(v, v)

Sets fixed linear velocity/acceleration for L-series motions (MoveL, MovePB, MoveLB, MoveITPL).

※ The value set in this function returns to the default value after the program ends.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Two variable types or constant numbers.
v: Speed/ Velocity (Unit: 𝒅𝒆𝒈/𝒔)
Does not lock the speed for negative input.
v: Acceleration (Unit: 𝒅𝒆𝒈/𝒔𝟐)
Does not lock the acceleration for negative input.
Return :
None.

Example :
# Ignoring the speed/acceleration set for each point of Move,
#set speed as 15 𝑚𝑚/𝑠, and acceleration as 5 𝑚𝑚/𝑠 2 .
set_speed_acc_l(15, 5)

# Ignoring the speed set for each point of Move,


#set speed as 5𝑚𝑚/𝑠.
set_speed_acc_l(5, -1)

38
set_speed_bar(v)

Set the overall speed control bar. (bottom speed control bar in UI).

※ When running a program on the UI Make page, this function does not work if the safety slide bar
option is turned on.
Input :
Single variable type or the constant number.
v: Desired speed control bar position (0~1)

Return :
None.

Example :
# Set the speed control bar to 50%.
set_speed_bar(0.5)

set_box_dout(v, v)

Set the digital output of the control box.


Two variable types or constant numbers.
v: Port number for the digital-output (0~15)
v: Output mode selection
-1 = Bypass
0 = Low
1 = High

Return :
None.

Example :
#Low output from port 0
set_box_dout(0, 0)

#Keep low on port 0


set_box_dout (0, -1)

# High output from port 0


set_box_dout (0, 1)

#Keep high on port 0


set_box_dout (0, -1)

39
set_box_aout(v, v)

Set the analog output of the control box.


Input :
Two variable types or constant numbers.
v: Port number for the analog output (0~3)
v: Desired output voltage (0~10V)

Return :
None.

Example :
#set 7V for the analog output port 3.
set_box_aout(3, 7)

set_box_dout_toggle(v)

Toggles the current digital output of the control box.


Input :
Single variable type or the constant number
v: Port number for the digital-output (0~15)

Return :
None.

Example :
# High output from port 1
set_box_dout (1, 1)
#Toggle the output port 1 ( Low signal will be out)
set_box_dout_toggle (1)

#Port 3 blinks every second


repeat (1 times){
set_box_dout_toggle(3)
wait (1 sec)
}

40
set_serial_tool(v, v, v)

Set the serial communication (RS232/485) provided by the Tool Flange of the robot arm.

※ The value set in this function returns to the default value after the program ends.
※ If this function is not called in program-flow, the value set in the Setup page is used.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Three variable types or constant numbers.
v: Communication speed (Baud rate)
v: Stop bit, (0 or 1, Default 1)
v: Parity bit, (0 : none, 1 : odd, 2 : even, Default 0)

Return :
None.

Example :
# Set tool-flange serial comm. : baud rate = 115200 / stop bit = 1 / parity = none
set_serial_tool(115200, 1, 0)

set_serial_box(v, v, v)

Set the serial communication (RS232/485) provided by the control box.

※ The value set in this function returns to the default value after the program ends.
※ If this function is not called in program-flow, the value set in the Setup page is used.
※ During program flow, the value set in this function is maintained until this function is called again.
Input :
Three variable types or constant numbers.
v: Communication speed (Baud rate)
v: Stop bit, (0 or 1, Default 1)
v: Parity bit, (0 : none, 1 : odd, 2 : even, Default 0)

Return :
None.

Example :
# Set control-box serial comm. : baud rate = 9600 / stop bit = 1 / parity = none
set_serial_box(9600, 1, 0)

41
arm_powerdown()

Turn off the power supply for the robot arm.

※ The robot arm powers down. Be careful with use. The control box does not turn off.
Input :
None.

Return :
None.

Example :
arm_powerdown()

42
freedrive_teach_on()

Turn on direct teaching mode (Free drive mode).

※ When this function is executed, the control mode of the robot arm is changed. Use with caution.
Input :
None.

Return :
None.

Example :

freedrive_teach_off()

Turn off direct teaching mode (Free drive mode).

※ When this function is executed, the control mode of the robot arm is changed. Use with caution.
Input :
None.

Return :
None.

Example :

43
jump_to(v)

Program execution is not executed until a specific address value.


Input :
Single variable type or the constant number.
v: Address value (0~99999)

Return :
None.

Example :
# Jumps through the program flow to the point where jump_here(1234) appears.
jump_to(1234)

jump_here(v)

Execute the program again from this point.

※ This function should be located at the top line (left) of the program.
Input :
Single variable type or the constant number.
v: Address value (0~99999)

Return :
None.

Example :
# In the example below, the middle two ‘wait’ lines will be ignored.
jump_to(1234)
wait (1.0 sec)
wait (2.0 sec)
jump_here(1234)

jump_to_line(v)

Jump to a specific line.


Input :
Single variable type or the constant number.
v: Address value (0~99999)
The line number is the number of the top line (left) of the program.
Begin is numbered in line 0, followed by line 1, in that order.

Return :
None.

Example :
# Go to line number 2.
jump_to_line(2)

44
jump_to_begin()

Move to the first starting line. Same effect as jump_to_line(0).


Input :
None.

Return :
None.

Example :
jump_to_begin()

45
6. SYSTEM VARIABLES

SD_TIME
SD_TIMER_0, SD_TIMER_1, …, SD_TIMER_9

A variable representing time.


It can be changed to the desired value in the Set function.
Used as a timer function.
Time automatically increments with the flow of program time.
(Unit: Second)
Example :

SD_J0_REF
SD_J1_REF
SD_J2_REF
SD_J3_REF
SD_J4_REF
SD_J5_REF

Joint reference angles. (Unit: degree)


Example :

SD_J0_ANG
SD_J1_ANG
SD_J2_ANG
SD_J3_ANG
SD_J4_ANG
SD_J5_ANG

Joint encoder angles. (Unit: degree)


Example :

SD_J0_CUR
SD_J1_CUR
SD_J2_CUR
SD_J3_CUR
SD_J4_CUR
SD_J5_CUR

Joint phase current. (Unit: A)


Example :

46
SD_BEGIN_J0
SD_BEGIN_J1
SD_BEGIN_J2
SD_BEGIN_J3
SD_BEGIN_J4
SD_BEGIN_J5

Variable representing the joint angles set in Begin. (Unit: degree)


Example :

SD_TEMPERATURE_MC0
SD_TEMPERATURE_MC1
SD_TEMPERATURE_MC2
SD_TEMPERATURE_MC3
SD_TEMPERATURE_MC4
SD_TEMPERATURE_MC5

Joint motor controller temperature. (Unit: celsius)

Example :

SD_TCP_X
SD_TCP_Y
SD_TCP_Z
SD_TCP_RX
SD_TCP_RY
SD_TCP_RZ

TCP values (position and orientation) with respect to the base (global) coordinate.
Example :

SD_DEFAULT_SPEED

Representing the default speed bar. The UI speed control bar value is displayed between 0 and 1.
Example :

SD_ROBOT_STATE

Indicates whether the robot motion command is being executed.


1 = Idle
3 = Moving
Example :

47
SD_POWER_STATE

Power information of the control box.


SD_POWER_STATE >> 0 & 0x01 : 48V SMPS State
SD_POWER_STATE >> 1 & 0x01 : Power switching information
SD_POWER_STATE >> 2 & 0x01 : 24V SMPS State
SD_POWER_STATE >> 3 & 0x01 : 48V switching information
SD_POWER_STATE >> 4 & 0x01 : User (PC) power selection information
SD_POWER_STATE >> 5 & 0x01 : Estop switch state
Example :

SD_COLLISION_DETECT_STATE

Whether the external collision detection function is on/off


0 = Collision detection mode off
1 = Collision detection mode on
Example :

SD_IS_FREE_DRIVE_MODE

Whether to use direct teaching


0 = Free-drive (Direct teaching) off
1 = Free-drive (Direct teaching) on
Example :

SD_PG_MODE

Indicates the robot's operation mode.


0 = Real mode
1 = Simulation mode
Example :

SD_INIT_STATE_INFO

This is a system variable representing the activation phase information of the robot.
Example :

SD_INIT_ERR

This is a system variable that indicates the robot activation error information.
Example :

48
SD_TFB_ANALOG_IN_0
SD_TFB_ANALOG_IN_1

Variable with analog value (0~10V) of two analog input ports of tool flange board (TFB).
Example :

SD_TFB_DIGITAL_IN_0
SD_TFB_DIGITAL_IN_1

A variable with a digital value (0 or 1) of the two digital input ports on the tool flange board (TFB).
Example :

SD_TFB_DIGITAL_OUT_0
SD_TFB_DIGITAL_OUT_1

A variable with an output value (0 or 1) of the two digital output ports of the tool flange board (TFB).
Example :

SD_TFB_VOLTAGE_OUT

It is a variable indicating the voltage output information (0 or 12 or 24V) of the tool flange board (TFB).
Example :

49
SD_OP_STAT_COLLISION_OCCUR

A variable indicating whether an external collision detected.


0 = Idle
1 = External collision detected
Example :

SD_OP_STAT_SOS_FLAG

A variable indicating if a control box power problem / robot joint controller / other problem has occurred.
0 = Idle
Example :

SD_OP_STAT_SELF_COLLISION

A variable indicating just before self-collision during robot motion.


0 = Idle
1 = Entering self-collision range
Example :

SD_OP_STAT_ESTOP_OCCUR

This is a variable indicating whether the program/robot is in the paused state.


0 = Idle
1 = Pause state
Example :

SD_OP_STAT_EMS_FLAG

This variable tells the user whether or not a singularity (= there is no solution for the robot control algorithm)
is present.
0 = Idle
Example :

50
SD_DIGITAL_IN_CONFIG_0
SD_DIGITAL_IN_CONFIG_1

Shows the information of the two protective stop terminals. (Din 16/17)
Example :

SD_INBOX_TRAP_FLAG_0
SD_INBOX_TRAP_FLAG_1

This is a variable that checks whether a specific part of the robot has entered a specific area (Inbox).
Example :

SD_INBOX_CHECK_MODE_0
SD_INBOX_CHECK_MODE_1

Inbox Check mode.


0: No checking
1: Check Tool Flange Center (check whether the TFC is in the Inbox area)
2: Check Tool Center Point (check whether the TCP is in the Inbox area)
3: Check Tool Box (Check whether the virtual box set at the end of the robot arm has entered in Inbox area.)
4: Check All (1,2,3)
Example :

51
SD_SOCK_IS_OPEN_0
SD_SOCK_IS_OPEN_1
SD_SOCK_IS_OPEN_2
SD_SOCK_IS_OPEN_3
SD_SOCK_IS_OPEN_4

This is a variable indicating whether the socket of the corresponding number was normally opened and whether
it was normally connected to the server. 1 (true) if creation and connection were performed normally. (# : 0~4)
Example :

SD_SOCK_LAST_READ_0
SD_SOCK_LAST_READ_1
SD_SOCK_LAST_READ_2
SD_SOCK_LAST_READ_3
SD_SOCK_LAST_READ_4

A variable indicating whether the read function was performed normally with the socket of the corresponding
number. 1 (true) if the read was performed normally.
(# : 0~4)
Example :

SD_HAND_TOKTOK

This is a variable indicating whether or not an act of tapping (tok tok) from outside the robot has occurred.
Example :

SD_FINISH_AT_EVENT

Stores whether the motion has ended in a way that the robot's FinishAt (motion escape) condition.
If the motion is finished by reaching the motion target point, this variable is 0.
If the FinishAt condition is satisfied and the operation is finished, this variable becomes 1.
Example :

SD_TCP_VEL_REF

TCP reference velocity.


Example :

SD_MOTION_TIME

It is a variable that stores the time of unit movement. When the next movement is executed, it starts from 0
again.
Example :

52
SD_ARM_POWER

A variable representing the power the robot is using.


Example :

SD_IS_TPU_CONNECT

This is a variable that indicates whether the TPU (Teaching Pendant Unit, Tablet PC) is connected.
Example :

SD_IS_RUN_IN_MAKE

1 is saved if the current program operation is executed in the Make page.


Example :

SD_IS_RUN_IN_PLAY

1 is saved if the current program operation is executed in the Play page.


Example :

SD_IS_INTENDED_STOP

Indicates whether the program termination is an intentional termination or an emergency termination.


Example :

SD_MOVE_INDEX

In a continuous motion such as MovePB / ITPL, it tells which point the robot is passing through.
Example :

53
7. MOVEMENT FUNCTIONS

move_finish_wait()

A function that waits for the currently executing movement to complete.


Input :
None.

Return :
None.

Example :
#Wait for the movement to complete until my_destination.
point my_destination = {100,200,300,0,0,0}
move_l(my_destination, 20, 5, 0)
move_finish_wait()

move_l(P, v, v, v=1)

A function that makes TCP to move in a straight line to the target point.
Input :
P: Target TCP posture
v: Speed (𝒎𝒎/𝒔)
v: Acceleration (𝒎𝒎/𝒔𝟐 )
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
point my_point1 = {100,200,300,0,0,0}
point my_point2= {100,150,100,0,90,0}

#MoveL method to move to my_point1.


move_l(my_point1, 20, 5)
#MoveL method to move to my_point2.
move_l(my_point2, 20, 5)

54
move_l_rel(P, v, v, v, v=1)

A function that makes TCP to move in a straight line to the target point.
Enter the target point as a value relative to the current TCP value.
Input :
P: Relative position & orientation value.
v: Speed (𝒎𝒎/𝒔)
v: Acceleration (𝒎𝒎/𝒔𝟐 )
v: reference frame for the relative P value.
0: Base (Global) coordinate.
1: Tool (Local) coordinate.
2: User coordinate 0
3: User coordinate 1
4: User coordinate 2
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :

# move TCP (0,100,-200) w.r.t. Base coordinate (speed/acceleration = 300 / 400)


move_l_rel(pnt[0,100,-200,0,0,0], 300, 400, 0)

# move TCP 50 mm w.r.t. x axis of User coordinate 2 (speed/acceleration = 100 / 300)


move_l_rel(pnt[50,0,0,0,0,0], 100, 300, 4)

55
move_j(J, v, v, v=1)

Move the robot arm to the target joint angle.


Input :
J: Target joint angles
v: Speed (Unit: 𝒅𝒆𝒈/𝒔)
v: Acceleration (Unit: 𝒅𝒆𝒈/𝒔𝟐 )
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
#move joint angles to (0,0,90,0,90,0) degree with speed/acceleration = 60/80.
move_j (jnt[0,0,90,0,90,0], 60, 80)

#move joint angles to (0,0,90,0,90,0) degree with speed/acceleration = 60/80.


jnt my_joint_angle = {0,0,90,0,90,0}
move_j (my_joint_angle, 60, 80)

move_jl(P, v, v, v=1)

(move joint with linear input)


This function moves to the target point using the move_j method rather than a straight line.
P: Target TCP posture
v: Speed (Unit: 𝒅𝒆𝒈/𝒔)
v: Acceleration (Unit: 𝒅𝒆𝒈/𝒔𝟐 )
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
point my_point1 = {100,200,300,0,0,0}
point my_point2 = {100,150,100,0,90,0}

#Move TCP to ‘my_point_1’ via MoveJ method.


move_jl(my_point1, 20, 5)
# Move TCP to ‘my_point_2’ via MoveJ method.
move_jl(my_point2, 20, 5)

56
move_pb_clear()

Initialize (Clear) the point list to be used in MovePB.


Input :
None.

Return :
None.

Example :
# Initialize (Clear) the point list to be used in MovePB.
move_pb_clear()

move_pb_add(P, v, v, v)

This function adds the points used in MovePB to the list.


Input :
P: Target TCP posture
v: Speed (Unit: 𝒎𝒎/𝒔)
v: Blending option
0 = Blend based on Ratio
1 = Blend based on Distance.
v: Blending value (0~1 / distance (mm) )

Return :
None.

Example :
point my_point1 = {100,200,0,0,0,0}
point my_point2 = {150,0,50,0,0,0}

# add ‘my_point1’ to the MovePB list with speed=50mm + 50% blending option
move_pb_add(my_point1, 50, 0, 0.5)

# add ‘my_point2’ to the MovePB list with speed=100mm + 50mm blending option
move_pb_add(my_point2, 100, 1, 50)

57
move_pb_run(v, v, v=1)

This function executes MovePB using the points added in move_pb_add.


Input :
v: Acceleration (Unit: 𝒎𝒎/𝒔𝟐 )
v: Orientation option
0 = Intended (Follows the rotation value taught by the user)
1 = Constant (Keep the rotation value of the starting position)
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
point my_point1 = {100,200,0,0,0,0}
point my_point2 = {150,0,50,0,0,0}

#Clear the MovePB list.


move_pb_clear()

#add the desired point to the list (my_point1)


move_pb_add(my_point1, 50, 0, 0.5)

# add the desired point to the list (my_point2)


move_pb_add(my_point2, 100, 1, 50)

# Move to my_point2 using the previously set blending options.


# At this time, the rotation value maintains the same value as the starting position.
move_pb_run(200, 1)

58
move_itpl_clear()

Initialize (Clear) the point list to be used in MoveITPL.


Input :
None.

Return :
None.

Example :
# Initialize (Clear) the point list to be used in MoveITPL.
move_itpl_clear()

move_itpl_add(P, v)

This function adds the points used in MoveITPL to the list.


Input :
P: Target TCP posture.
v: Speed (Unit: 𝒎𝒎/𝒔)

Return :
None.

Example :
point my_point1 = {100,200,0,0,0,0}
point my_point2 = {150,0,50,0,0,0}

# add ‘my_point1’ to the MoveITPL list with speed=50mm


move_itpl_add(my_point1, 50)

# add ‘my_point2’ to the MoveITPL list with speed=100mm


move_itpl_add(my_point2, 100)

59
move_itpl_run(v, v, v=1)

This function executes MoveITPL using the points added in move_itpl_add.


Input :
v: Acceleration
v: Orientation/motion option
0 = Intended (Follows the rotation value taught by the user)
1 = Constant (Keep the rotation value of the starting position)
2 = Reserved (N/A)
3 = Smooth (Similar to Intended, but with a smooth rate of rotation change)

4 = Reserved (N/A)

5 = CA-Intended (CA mode Intended)


6 = CA-Constant (CA mode Constant)
7 = Reserved (N/A)
8 = CA-Smooth (CA mode Smooth)
CA: Combined Arc mode
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
point my_point1 = {100,200,0,0,0,0}
point my_point2 = {150,0,50,0,0,0}

#Clear the MoveITPL list


move_itpl_clear()

#add ‘my_point1’ to the MoveITPL list with speed = 50mm/s


move_itpl_add(my_point1, 50)

# add ‘my_point2’ to the MoveITPL list with speed = 100mm/s


move_itpl_add(my_point2, 100)

#Move to ‘my_point2’ with move_itpl type movement.


# In this case, the rotation value taught by the user is used.
move_itpl_run(200, 1)

60
move_lc_clear()

Initialize (Clear) the point list to be used in MoveLC.


Input :
None.

Return :
None.

Example :
# Initialize (Clear) the point list to be used in MoveLC.
move_lc_clear()

move_lc_add(P, v, v)

This function adds the points used in MoveLC to the list.


Input :
P: Target TCP posture.
v: Speed (Unit: 𝒎𝒎/𝒔)
v: Property (0 or 1)
0 = Pass through linear motion
1 = Pass through circular motion

Return :
None.

Example :
point my_point1 = {100,200,0,0,0,0}
point my_point2 = {150,0,50,0,0,0}

#add ‘my_point1’ to the MoveLC list with velocity 50mm/s.


move_lc_add(my_point1, 50, 1)

# add ‘my_point2’ to the MoveLC list with velocity 100mm/s .


move_lc_add(my_point2, 100, 0)

61
move_lc_run(v, v, v=1)

This function executes MoveLC using the points added in move_lc_add.


Input :
v: Acceleration
v: Orientation options
0 = Intended (Follows the rotation value taught by the user)
1 = Constant (Keep the rotation value of the starting position)
2 = Reserved (N/A)
3 = Smooth (Similar to Intended, but with a smooth rate of rotation change)
4 = Reserved (N/A)

v: Wait flag (default: 1)


0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
point my_point1 = {100,200,0,0,0,0}
point my_point2 = {150,0,50,0,0,0}

#clear the MoveLC list


move_lc_clear()

#add ‘my_point1’ to the list


move_lc_add(my_point1, 50, 1)

# add ‘my_point2’ to the list


move_lc_add(my_point2, 100, 0)

#Use the linear&circular motion to move up to my_point2.


# In this case, the rotation value taught by the user is used for the rotation value.
move_lc_run(200, 1)

62
move_lb_clear()

Initialize (Clear) the point list to be used in MoveLB.


Input :
None.

Return :
None.

Example :
#Initialize (Clear) the point list to be used in MoveLB.
move_lb_clear()

move_lb_add(P, v)

This function adds the points used in MoveLB to the list.


Input :
P: Target TCP posture.
v: Blend distance (Unit (mm))
※ Unlike MovePB, it does not support ratio blending.

Return :
None.

Example :
point my_point1 = {100,200,0,0,0,0}
point my_point2 = {150,0,50,0,0,0}

#add ‘my_point1’ to the MoveLB list + blending distance = 20mm


move_lb_add(my_point1, 20)

#add ‘my_point2’ to the MoveLB list + blending distance = 20mm


move_lb_add(my_point2, 20)

63
move_lb_run(v, v, v, v=1)

This function executes MoveLB using the points added in move_lb_add.


Input :
v: Speed (Unit: 𝒎𝒎/𝒔)
v: Acceleration (Unit: 𝒎𝒎/𝒔𝟐 )
v: Orientation options
0 = Intended (Follows the rotation value taught by the user)
1 = Constant (Keep the rotation value of the starting position)
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
point my_point1 = {100,200,0,0,0,0}
point my_point2 = {150,0,50,0,0,0}

#clear MoveLB list.


move_lb_clear()

#add ‘my_point1’ to the MoveLB list.


move_lb_add(my_point1, 20)

#add ‘my_point2’ to the MoveLB list.


move_lb_add(my_point2, 20)

# Move to ‘my_point2’ using the previously set distance 20mm blending option.
# At this time, the rotation value maintains the same value as the starting position.
move_lb_run(50, 20, 1)

64
move_c_points(P, P, v, v, v, v=1)

This function performs a movement that draws an arc through via & target points.
Input :
P: via Point TCP posture
P: target Point TCP posture
v: Speed (Unit: 𝒎𝒎/𝒔)
v: Acceleration (Unit: 𝒎𝒎/𝒔𝟐 )
v: Orientation options
0 = Intended (Follows the rotation value taught by the user)
1 = Constant (Keep the rotation value of the starting position)
2 = Radial (Rotate the TCP according to the rotation of the circle)
3 = Smooth (Similar to Intended, but with a smooth rate of rotation change)
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
point my_point1 = {100,100,300,0,90,0}
point my_point2 = {200,200,200,0,90,45}

# Using ‘my_point1’ as a via-waypoint, it moves in an arc to ‘my_point2’.


# Based on the center point of the rotation, the orientation of the TCP is changed together.
move_c_points(my_point, my_point2, 50, 10, 2)

65
move_c_axis(P, v, v, v, v, v, v, v, v=1)

This function performs an arc movement using the rotation center and rotation axis information.
Input :
P: Center of the rotation (Unit: mm)
v: rotation axis’s x axis vector
v: rotation axis’s y axis vector
v: rotation axis’s z axis vector
v: rotation angle (Unit: deg)
v: Speed (Unit: 𝒎𝒎/𝒔)
v: Acceleration (Unit: 𝒎𝒎/𝒔𝟐 )
v: Rotation options
0 = Intended (rotate the same way as the Constant below.)
1 = Constant (Keep the rotation value of the starting position)
2 = Radial (Rotate the TCP according to the rotation of the circle)

v: Wait flag (default: 1)


0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.
Example :
point my_point = {200,200,200,0,0,0}

# Rotate 180 degrees around the x-axis. Center of rotation is ‘my_point’.


# Based on the center point of the rotation, the orientation of the TCP is changed together.
move_c_axis(my_point, 1, 0, 0, 180, 50, 10, 2)

66
move_jb_clear()

Initialize (Clear) the point list to be used in MoveJB.


Input :
None.

Return :
None.

Example :
#Initialize (Clear) the point list to be used in MoveJB.
move_jb_clear()

move_jb_add(J)

This function adds the joint-angles used in MoveJB to the list.


Input :
J: Target joint angles

Return :
None.

Example :
jnt my_joint1 = {0, 0,0,0,0,0}
jnt my_joint2 = {90,30,15,0,0,0}

#add ‘my_joint1’ to the MoveJB list.


move_jb_add(my_joint1)

#add ‘my_joint2’ to the MoveJB list.


move_jb_add(my_joint2)

67
move_jb_run(v, v, v=1)

This function executes MoveJB using the points added in move_jb_add.


Input :
v: Speed (𝒅𝒆𝒈/𝒔)
v: Acceleration (𝒅𝒆𝒈/𝒔𝟐 )
v: Wait flag (default: 1)
0 = No Wait (Non-Block).
1 = Wait for the movement to complete (Block).

Return :
None.

Example :
jnt my_joint1 = {0, 0,0,0,0,0}
jnt my_joint2 = {90,30,15,0,0,0}

#Clear the MoveJB list.


move_jb_clear()

#add ‘my_joint1’ to the MoveJB list.


move_jb_add(my_joint1)

#add ‘my_joint2’ to the MoveJB list.


move_jb_add(my_joint2)

# Moves smoothly without stopping to the previously set joint angles.


move_jb_run(50, 20)

68
8. GRIPPERS AND SENSORS

gripper_rtq_hande_init(v)

Robotiq - Hand-E gripper initialization.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_hande_init(1)
#When the gripper communication line is connected to the control box

gripper_rtq_hande_reset(v)

Robotiq - Hand-E gripper reset.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_hande_reset(1)
#When the gripper communication line is connected to the control box

69
gripper_rtq_hande_go(v, v, v, v)

Robotiq - Hand-E gripper movement.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target position % (Range: 0~100)
v: Target Velocity % (Range: 0~100)
v: Target Force % (Range: 0~100)

Return :
None.

Example :
#Move the gripper connected to the control box to position 100%. (with speed 50%, force 100%)
gripper_rtq_hande_go(1, 100, 50, 100)

gripper_rtq_2f85_init(v)

Robotiq – 2F85 gripper initialization.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_2f85_init(1)
#When the gripper communication line is connected to the control box

gripper_rtq_2f85_reset(v)

Robotiq – 2F85 gripper reset.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_2f85_reset(1)
#When the gripper communication line is connected to the control box

70
gripper_rtq_2f85_go(v, v, v, v)

Robotiq – 2F85 gripper movement.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target position % (Range: 0~100)
v: Target Velocity % (Range: 0~100)
v: Target Force % (Range: 0~100)

Return :
None.

Example :
#Move the gripper connected to the control box to position 100%. (with speed 50%, force 100%)
gripper_rtq_2f85_go(1, 100, 50, 100)

gripper_rtq_2f140_init(v)

Robotiq – 2F140 gripper initialization.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_2f140_init(1)
#When the gripper communication line is connected to the control box

gripper_rtq_2f140_reset(v)

Robotiq – 2F140 gripper reset.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_2f140_reset(1)
#When the gripper communication line is connected to the control box

71
gripper_rtq_2f140_go(v, v, v, v)

Robotiq – 2F140 gripper movement.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target position % (Range: 0~100)
v: Target Velocity % (Range: 0~100)
v: Target Force % (Range: 0~100)

Return :
None.

Example :
#Move the gripper connected to the control box to position 100%. (with speed 50%, force 100%)
gripper_rtq_2f140_go(1, 100, 50, 100)

gripper_rtq_epick_reset(v)

Robotiq – E-pick gripper reset.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_epick_reset(1)
#When the gripper communication line is connected to the control box

gripper_rtq_epick_suction(v)

Robotiq – E-pick gripper suction.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_epick_suction(1)
#When the gripper communication line is connected to the control box

72
gripper_rtq_epick_release(v)

Robotiq – E-pick gripper release.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_epick_release(1)
#When the gripper communication line is connected to the control box

gripper_rtq_epick_hold(v)

Robotiq – E-pick gripper hold.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rtq_epick_hold(1)
#When the gripper communication line is connected to the control box

gripper_rts_rhp12rn_init(v)

Robotis – RHP12RN gripper initialization.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_rts_rhp12rn_init(1)
#When the gripper communication line is connected to the control box

73
gripper_rts_rhp12rn_go(v, v)

Robotis – RHP12RN gripper movement.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target position % (Range: 0~100)

Return :
None.

Example :
gripper_rts_rhp12rn_go(1, 100)
#Move the gripper connected to the control box to 100% position.

gripper_jrt_jegb485_init(v)

JRT – JEGB485 gripper initialization.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_jrt_jegb485_init(1)
#When the gripper communication line is connected to the control box

gripper_jrt_jegb485_go(v, v)

JRT – JEGB485 gripper movement.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target position % (Range: 0~100)

Return :
None.

Example :
gripper_jrt_jegb485_go(1, 100)
#Move the gripper connected to the control box to 100% position.

74
gripper_jrt_jegb485_go(v, v, v, v)

JRT – JEGB485 gripper movement with advanced setting.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target position % (Range: 0~100)
v: Target speed % (Range: 0~100)
v: Target acceleration % (Range: 0~100)

Return :
None.

Example :
#Move the gripper connected to the control box to 100% position. (with speed & acceleration 50%)
gripper_jrt_jegb485_go(1, 100, 50, 50)

gripper_jrt_jegb485_set(v, v, v, v)

JRT – JEGB485 gripper setting.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target speed % (Range: 0~100)
v: Target acceleration % (Range: 0~100)
v: Target force % (Range: 0~100)

Return :
None.

Example :
#Set the motion properties speed/acceleration/force of the gripper connected to the control box to 50, 30, and
20%, respectively
gripper_jrt_jegb485_set(1, 50, 30, 20)

gripper_jrt_jegb4140_init(v)

JRT – JEGB4140 gripper initialization.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_jrt_jegb4140_init(1)
#When the gripper communication line is connected to the control box

75
gripper_jrt_jegb4140_go(v, v)

JRT – JEGB4140 gripper movement.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target position % (Range: 0~100)

Return :
None.

Example :
gripper_jrt_jegb4140_go(1, 100)
#Move the gripper connected to the control box to 100% position.

gripper_jrt_jegb4140_go(v, v, v, v)

JRT – JEGB4140 gripper movement with advanced setting.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target position % (Range: 0~100)
v: Target speed % (Range: 0~100)
v: Target acceleration % (Range: 0~100)

Return :
None.

Example :
#Move the gripper connected to the control box to 100% position. (with speed & acceleration 50%)
gripper_jrt_jegb4140_go(1, 100, 50, 50)

gripper_jrt_jegb4140_set(v, v, v, v)

JRT – JEGB4140 gripper setting.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
v: Target speed % (Range: 0~100)
v: Target acceleration % (Range: 0~100)
v: Target force % (Range: 0~100)

Return :
None.

Example :
#Set the motion properties speed/acceleration/force of the gripper connected to the control box to 50, 30, and
20%, respectively
gripper_jrt_jegb4140_set(1, 50, 30, 20)

76
gripper_dh_ag95_init(v)

DH Robotics – AG95 gripper initialization.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box

Return :
None.

Example :
gripper_dh_ag95_init(1)
#When the gripper communication line is connected to the control box

gripper_dh_ag95_gripforce(v, v)

DH Robotics – AG95 gripper grip-force setting.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
V: Gripping force % (20 ~ 100 %)

Return :
None.

Example :
# Set the gripping force limit of the gripper connected to the control box to 30%.
gripper_dh_ag95_gripforce(1, 30)

gripper_dh_ag95_openforce(v, v)

DH Robotics – AG95 gripper open-force setting.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
V: Opening force % (20 ~ 100 %)

Return :
None.

Example :
#Set the opening force limit of the gripper connected to the control box to 70%.
gripper_dh_ag95_openforce(1, 70)

77
gripper_dh_ag95_go(v, v)

DH Robotics – AG95 gripper movement.


Input :
v: Connection port for the Gripper/Sensor.
0 = RS485 of the Tool Flange board.
1 = RS485 of the Control Box
V: Target position % (0 ~ 100 %)

Return :
None.

Example :
#Move the gripper connected to the control box to the 50% position.
gripper_dh_ag95_go(1, 50)

gripper_setech_cmd(v)

Setech –NutRunner
Input :
v: Command number
0 = Stop
1 = Reset
2 = Quick Start
3 = First stage
4 = Second stage
5 = Reverse

Return :
None.

Example :
gripper_setech_cmd( #)

78
9. COMMUNICATION FUNCTIONS

mc_comm_set_bit(v, S, v, v=1)

It sends the desired bit data (1 bit) to the desired address value of the PLC equipment. (via MC Protocol
provided by Mitsubishi)
Input :
v: Index of Socket-Handler. (0~4)
S: address of the PLC (string type)
* address value is in the form of D~~~~ X~~~~, etc.
v: Desired bit data (0 or 1)
v: Handshake signal Timeout (Unit: second) (default: 1)

Return :
v: Whether or not a valid (Handshake) signal is received from the PLC
0: Receive Fail
1: Receive Success

Example :
# Using socket 0, send value 1 to PLC address D2000.
str target_address = “D2000”
var target_write_value = 1
var is_tx_success = mc_comm_set_bit(0, target_address, target_write_value)
# Same meaning can be written as below.
var is_tx_success = mc_comm_set_bit(0, “D2000”, 1)

79
mc_comm_set_word(v, S, v, v=1)

It sends the desired word data (16 bits) to the desired address value of the PLC equipment. (via MC Protocol
provided by Mitsubishi)
Input :
v: Index of Socket-Handler. (0~4)
S: address of the PLC (string type)
* address value is in the form of D~~~~ X~~~~, etc.
v: Desired word data
v: Handshake signal Timeout (Unit: second) (default: 1)

Return :
v: Whether or not a valid (Handshake) signal is received from the PLC.
0: Receive Fail
1: Receive Success

Example :
# Using socket 0, send value 150 to PLC address D2000.
str target_address = “D2000”
var target_write_value = 150
var is_tx_success = mc_comm_set_word(0, target_address, target_write_value)
# Same meaning can be written as below.
var is_tx_success = mc_comm_set_word(0, “D2000”, 150)

mc_comm_req_bit(v, S, v=1)

It reads the desired bit data (1 bit) from the desired address value of the PLC equipment. (via MC Protocol
provided by Mitsubishi)
Input :
v: Index of Socket-Handler. (0~4)
S: address of the PLC (string type)
* address value is in the form of D~~~~ X~~~~, etc.
v: Handshake signal Timeout (Unit: second) (default: 1)

Return :
v: Bit data value received from PLC.
-1: Receive fail
0 or 1: Received bit value

Example :
# Using socket 0, read bit value from the PLC address D2000.
str target_address = “D2000”
var rx_data = mc_comm_req_bit(0, target_address)
# Same meaning can be written as below.
var rx_data = mc_comm_req_bit(0, “D2000”)

80
mc_comm_req_word(v, S, v=1)

It reads the desired word data (16 bits) from the desired address value of the PLC equipment. (via MC Protocol
provided by Mitsubishi)
Input :
v: Index of Socket-Handler. (0~4)
S: address of the PLC (string type)
* address value is in the form of D~~~~ X~~~~, etc.
v: Handshake signal Timeout (Unit: second) (default: 1)

Return :
v: Word data value received from PLC.
-1 : Receive fail

Example :
# Using socket 0, read word value from the PLC address D2000.
str target_address = “D2000”
var rx_data = mc_comm_req_word(0, target_address)
# Same meaning can be written as below.
var rx_data = mc_comm_req_word(0, “D2000”)

81
socket_connect(v, S, v)

Opens a socket port for TCP/IP communication and connects to the server.
Input :
v: Index of Socket-Handler. (0~4)
S: IP address of the target server (string type)
*i.e. ”192.168.0.10”
v: Port number of the target server.

Return :
None.

Example :
# Using socket 0, connect to port 5678 of the server address “192.168.0.10”
socket_connect(0, “192.168.0.10”, 5678)

socket_disconnect(v)

Closes the socket port for TCP/IP communication and disconnects.


Input :
v: Index of Socket-Handler. (0~4)

Return :
None.

Example :
# Disconnect opened communication on socket 0 and exit.
socket_disconnect(0)

socket_send_str(v, S)

Transmits a string to the server through TCP/IP communication.


Input :
v: Index of Socket-Handler. (0~4)
S: Target string for the transmission.

Return :
None.

Example :
# Send “hello world” to the server where socket 0 is connected.
socket_send_str(0, “hello world”)

# Transmit the variable value as a string to the server connected to socket 0


var my_var = 1234
socket_send_str(0, to_str(my_var))

82
socket_read_str(v)

Returns the string received from the server through TCP/IP communication.
Input :
v: Index of Socket-Handler. (0~4)

Return :
S: Received string from the server

Example :
# Receives a string from the server connected to socket 0, and if there is a received string, it is displayed in the
alarm window.
# When the server sends “rainbow”, “rainbow” is stored in the receivce_str string variable.

str receive_str = socket_read_str(0)


if (SD_SOCKET_LAST_READ_0){
debug “receive_str”
}

socket_read_var(v)

If the string received from the server through TCP/IP communication is in the form of a number, it is returned
as a number..
Input :
v: Index of Socket-Handler. (0~4)

Return :
v: Received number from the server

Example :
# Receives a string from the server connected to socket 0, and converts the received string into a numeric
variable. And if there is a reception, it is displayed in the alarm window.
#When the server sends “123.456”, 123.456 is stored in the receivce_var.

var receive_var = socket_read_var(0)


if (SD_SOCKET_LAST_READ_0){
debug “receive_var”
}

83
hmi_set_one_word (v, v, v, v=1)

It sends the desired word data (16 bits) to the desired address value of the HMI equipment. (via Memory-Link
by Proface/TOP)
Input :
v: Index of Socket-Handler. (0~4)
v: HMI address value (0~9999)
v: desired value for transmission (variable)
v: Handshake signal Timeout (Unit: second) (default: 1)

Return :
v: Whether or not a valid (Handshake) signal is received from the HMI.
0: Receive Fail
1: Receive Success

Example :
# Using socket 0, send the value 150 to HMI address 6000.
var target_address = 6000
var target_write_value = 150
var is_tx_success = hmi_set_one_word(0, target_address, target_write_value)
# Same meaning can be written as below.
var is_tx_success = hmi_set_one_word(0, 6000, 150)

hmi_set_multi_word (v, v, v, v=1, A)

It sends the desired word data-s (16 bits x desired length) to the desired address area of the HMI equipment.
(via Memory-Link by Proface/TOP)
Input :
v: Index of Socket-Handler. (0~4)
v: starting HMI address value (0~9999)
v: Number of data to send to HMI device (Max 20)
v: Handshake signal Timeout (Unit: second) (default: 1)
A: Array name to send

Return :
v: Whether or not a valid (Handshake) signal is received from the HMI.
0: Receive Fail
1: Receive Success

Example :
# Using socket 0, send the 4 values (150, 160, 200, 210) stored in the array to the 4 address values (6000 ~
6003) of the HMI.
arr my_arr = {150, 160, 200, 210}
var is_tx_success = hmi_set_multi_word(0, 6000, 4, my_arr)

84
hmi_req_one_word (v, v, v=1)

It reads the desired word data (16 bits) from the desired address value of the HMI equipment. (via Memory-
Link provided by Proface/TOP)
Input :
v: Index of Socket-Handler. (0~4)
v: HMI address value (0~9999)
v: Handshake signal Timeout (Unit: second) (default: 1)

Return :
v: Value stored in the corresponding address value of the HMI

Example :
# Using socket 0, read the value of HMI address 7000 and store it in the variable my_num.
var my_num
my_num = hmi_req_one_word(0, 7000)

hmi_req_multi_word (v, v, v, v=1)

It reads the desired word data-s (16 bits x desired length) from the desired address area of the HMI equipment.
(via Memory-Link provided by Proface/TOP)
Input :
v: Index of Socket-Handler. (0~4)
v: starting HMI address value (0~9999)
v: Number of data to read from HMI device (Max 20)
v: Handshake signal Timeout (Unit: second) (default: 1)

Return :
A: Array name to store data received from HMI

Example :
# Using socket 0, read 10 values (address values 7000~7009) from HMI and store them in the array ‘my_array’.
arr my_array
my_array = hmi_req_multi_word(0, 7000, 10)

85
10. VECTOR

A vector refers to a dynamically allocated variable type. An array of unspecified length.


Often, in languages like C++, they are declared in the form vector<float> or vector<string> .
Rainbow Robotics' script system supports both numeric vectors and string vectors, each
corresponding to the C++ standard, vector<float> and vector<string>.

Number Vector

# The declaration uses the declarator vec .


vec hello_world

# Initialization is possible at the same time as declaration.


vec hello_world = {10, 20, 30}

# The length of the vector can be obtained with the vec_length (or vec_leng) function.
# In this case, the input argument of the function is the name of the vector.
var num = vec_length( hello_world)

# To add an argument to a vector, use the vec_push (or vec_push_back, or vec_add) function.
# In this case, the input argument of the function is the name of vector and the number to be added.
vec_push( hello_world, 40)
vec_push( hello_world, 50)

# Vector can be cleared through the vec_clear (or vec_clr) function.


# In this case, the input argument of the function is the name of the vector.
vec_clear(hello_world)

# If you want to refer to the value stored in the vector, use the vec_at function.
# In this case, the input parameters of the function are the name of the vector and the index to be referenced.
# Index references are also possible through the [] operator.
var value = vec_at(hello_world, 2)
var value = hello_world[2]

Example :

vec mung = {10, 20} # declare vector. Name = mung, initial values are 10 and 20
var my_num = vec_length(mung) # my_num = 2 (length of the vector)
vec_push( mung, 30) # Add the number 30 to the end of the mung vector
vec_push( mung, 40) # Add the number 40 to the end of the mung vector
var my_num = vec_length(mung) # my_num = 4 (length of the vector)
var a = vec_at(mung, 1) # a = 20 (value saved in the index 1 of the vector mung)
var b = mung[3] # b = 40 (value saved in the index 3 of the vector mung)
vec_clear(mung) # clear the vector mung
var my_num = vec_length(mung) # my_num = 0 (length of the vector)

86
For string vectors, the usage of functions is the same as for numeric vectors.
However, due to system memory limitations, only predefined names can be used for string vectors.
There are 10 string vectors defined in the system as shown below. Users can use the string vector with
the name immediately below without having to declare it.
Predefined string vectors: str_vec_0, str_vec_1, str_vec_2, str_vec_3, str_vec_4
str_vec_5, str_vec_6, str_vec_7, str_vec_8, str_vec_9
The functions used for vectors are the same as for numeric vectors introduced in the previous chapter.

String Vector
Example :

vec_push(str_vec_3, “hello”) # add “hello” to the string vector ‘str_vec_3’


vec_push(str_vec_3, “world”) # add “world” to the string vector ‘str_vec_3’
var my_num = vec_length(str_vec_3) # my_num = 2 (length of the vector)
vec_push(str_vec_3, “aa”) # add “aa” to the string vector ‘str_vec_3’
vec_push(str_vec_3, “bb”) # add “bb” to the string vector ‘str_vec_3’
var my_num = vec_length(str_vec_3) # my_num = 4 (length of the vector)
str sa = vec_at(str_vec_3, 1) # “world” is stored in ‘sa’ with reference to str_vec_3 vector index 1.
str sb = str_vec_3[3] # “bb” is stored in ‘sb’ with reference to str_vec_3 vector index 3.
vec_clear(str_vec_3) # clear the string vector ‘str_vec_3’
var my_num = vec_length(str_vec_3) # my_num = 0 (length of the vector)

87
- Rainbow Robotics Research Center -

88

You might also like