Teach Pendant Scripting Interface Manual (V4.5.4)
Teach Pendant Scripting Interface Manual (V4.5.4)
Teach Pendant Scripting Interface Manual (V4.5.4)
Scripting Interface
Manual
V4.5.4
⚫ The user manual will be checked and corrected periodically. The updated
content will appear in the new version. The content or information in this
manual is subject to change without notice.
⚫ Please read this manual before installing and using the product.
⚫ Please keep this manual so that you can read and refer to it at any time.
⚫ The contents described in this manual do not exclude the possibility of mistakes
or omissions. If you have any questions about the contents of this manual,
please contact our company.
Identifiers can be consisted of any letter that begins with a non-numeric character,
a string of underscores and numbers and can be used to name variables, functions, etc.
The following keywords are reserved and cannot be used to name identifiers:
a _abc a_123
“abcdef”
a={1.0,0.2,3.0}
The comment begins with a double dash (--), followed by the closing braces [[for
section notes, up to the corresponding]], otherwise it is a one-line comment to the end
of the current line.
The scope of the global variable is different from that of the local variable. Before the
local variable is declared, the local keyword is added. For example,
local a=5
Arithmetic expression
6+2-3
5*2/3
(2+3)*4/(5-6)
Logical expression
Variable assignment
A = 100
bar = ture
PI = 3.1415
name = “Lily”
positon = {0.1,-1.0,0.2,1.0,0.4,0.5}
The variable type in AUBOScript does not need to be modified, but is derived from the
first assignment of the variable. For example, in the above example, A is an integer, bar
is a boolean, PI is a float, name is a string, and position is an array.
The basic variable types in AUBOScript are: Number, Boolean, String, and Array
The control flow of the program can be implemented through the control
structures if, while, repeat, and for. In AUBOScript, their grammar rules conform to the
usual definitions. The syntax is:
if(exp1) then
E.g
a= -2
if(a<0) then
print(“a<0”)
elseif(a>0) then
print(“a>0”)
else
print(“a=0”);
end
while(exp) do
--Forever loop
while(true) do
print(“A”);
end
repeat
A = 10
repeat
print(A)
A = A+1
until(A>15)
end
do
print(i)
You can use break to stop a loop and use the goto statement to implement a jump.
You can use return to return directly. In particular, AUBOScript does not support the
continue statement, but it can be implemented indirectly using goto.
Math operator:
+ Addition
* Multiplication
¬ Subtraction
Floating point
/
division
// Down-division
% Modulo
^ Power
¬ Negative
Bit operators:
| Bitwise OR
~ Bitwise XOR
~ Bitwise NOT
Comparison operators:
== Equal
~= Not equal
Logical operators:
and or not
or
and
&
<< >>
..
+ -
* / // %
not ( # ¬ ~)
You can use parentheses to change the order of operations. The connection
operator ('..') and the power operation ('^') are from right to left. All other operations
are from left to right.
1.4 Functions
function MyFunc(param)
end
function add(a,b)
return (a+b)
end
Function call:
x= add(3,4)
The function can have no return value, or it can have one or more return values, for
example:
function add(a,b)
return a,b,(a+b)
end
Function call:
x,y,z=add(a,b)
startServer(1001)
while 1 do
strccd = recData("192.168.1.101") --Camera side IP address (external device IP address)
if dd then
robotPrintf(dd)
str =string.sub(strccd, starting position, length) -- Gets the string of the specified
position and length
string.len (target string) -- Get the length of the string
Function call:
function string.split(str, delimiter) -- Split string, delimited string, return array, str
String to delimit, delimiter delimiter
if str==nil or str=='' or delimiter==nil then
return nil
end
local result = {}
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
1.4.5 String
string.sub(s,i,j) The function intercepts the string from the i-th character to the
j-th character of the string s.
string.sub(s, 2, -2) Returns the substring after removing the first and last characters.
s = "[abc]"
string.len(s) <==return 5
string.rep("abc", 2) <==return "abcabc"
string.lower("ABC") <==return "abc"
string.upper("abc") <==return "ABC"
string.sub(s, 2) <==return "abc]"
string.sub(s, -2) <==return "c]"
string.sub(s, 2, -2) <==return "abc"
Note: All of the interfaces below require the transfer of posture parameters in quaternion form.
When Euler angles are used, the rpy2quaternion interface conversion can be used. Euler angle
defines the rotation sequence as Z, Y, X.
Must pass parameters: must pass in any case, need a default value even if it’s not in use.
Selection parameters: Users can chose to pass or not according to the function of the parameter
description and business logic.
Bundled parameters: Associated with a parameter, select the transfer method according to the
parameter description of the function.
Must not pass parameters: must not be passed, generally used in conjunction with the bundling
parameters, refer to the parameter description of the function.
Tool parameters: consisting of tool kinematic parameters and tool dynamic parameters
Tool kinematics parameters (aka: end-of-tool parameters): Consists of tool end position
parameters and tool end attitude parameters. This parameter can also describe the tool
coordinate system.
Note: The center of the flange is a special tool and tool coordinate system.
When used as a tool, the tool end position parameter is (0, 0, 0), the tool end attitude parameter
is (1, 0, 0, 0), the tool load is 0, and the center of gravity is (0, 0, 0);
When used as a tool coordinate system, the tool end position parameter is (0, 0, 0) and the tool
end attitude parameter is (1, 0, 0, 0).
The tool and tool coordinate systems mentioned in the parameter descriptions below contain the
flange center.
The base coordinate system is a special user coordinate system. It can be understood that the
base coordinate system is a user coordinate system that coincides with the origin of the robot
base coordinate system and the three axes coincide.
2.3 Tips
The interface sequence in this document is not based on the calling sequence in the example. It is
mainly based on the function category. If there is any interface or variable name that is not
mentioned above in the sample program, please search for it by yourself or find the interface
below. variable name.
The contents of all red words are very important. Please read them carefully.
Project folder:
The directory where function files are stored corresponds to the following figure:
Script folder:
The directory where script files are stored corresponds to the following figure:
SI00 SI10
SI01 SI11
SI02 SI12
SI03 SI13
SI04 SI14
SI05 SI15
SI06 SI16
SI07 SI17
SO00 SO10
SO01 SO11
SO02 SO12
SO03 SO13
SO04 SO14
4.2 User IO
U_DI_00
U_DI_01
U_DI_02
U_DI_03
U_DI_04
U_DI_05
U_DI_06
U_DI_07
U_DI_10
U_DI_11
U_DI_12
U_DI_13
U_DI_14
U_DI_15
U_DI_16
U_DI_17
4.2.2 16 DO
U_DO_00
U_DO_01
U_DO_02
U_DO_03
U_DO_04
U_DO_05
U_DO_06
U_DO_07
U_DO_10
U_DO_11
U_DO_12
U_DO_13
U_DO_14
U_DO_15
U_DO_16
U_DO_17
VI0
VI1
VI2
VI3
4.2.4 4 AO
VO0
VO1
CO0
CO1
4.3 Tool IO
T_DI/O_00
T_DI/O_01
T_DI/O_02
T_DI/O_03
4.3.2 2 AI
T_AI_00
T_AI_01
Onboard IO type:
enum RobotIOType{
RobotBoardControllerDI,
RobotBoardControllerDO,
RobotBoardControllerAI,
RobotBoardControllerAO,
RobotBoardUserDI,
RobotBoardUserDO,
RobotBoardUserAI,
RobotBoardUserAO,
RobotToolDI,
double asin(double f)
Return to the main arcsine of f in radians. A runtime error occurs if f is outside the
Features
range [-1, 1]
Parameter f Float value
return
Arc sine f, float value
Value
double atan(double f)
Features Returns to arc tangent of f (in radians)
Parameter f Float value
Return
Arctangent f, float value
Value
double cos(double f)
Features Returns to the cosine of the f, radians angle
Parameter f Float value
Return
Cosine f, float value
Value
double sin(double f)
Features Returns to the sine of the f, radians angle
©2015-2021 AUBO all rights reserved 27 V4.5.4
Parameter f Float value
Return
Sine f, float value
Value
double tan(double f)
Features Return to tangent f
Parameter f Float value
Return
Tangent f, float value
Value
double sqrt(double f)
Features Returns to the square root of f. If f is negative, a runtime error occurs
Parameter f Float value
Return
Square root of f, float value
Value
int ceil(double x)
Features Floats round to the smallest integer not less than f.
Parameter f Float value
Return Rounded integer
int floor(double x)
Features Rounds a floating-point number to the largest integer not greater than f
Parameter f Float value
Return
Rounded integer
Value
double r2d(double r)
Features Return to radians r converted to angle values
double d2r(double d)
Features return to the radian value of the d degree. In fact: (d/180)* PI
Parameter d Angle in degrees
Return
Angle in radians, float value
Value
Parameter r Radians
Return
Angle value, float value
Value
{oriRX,oriRY,oriRZ} quaternion2rpy({oriW,oriX,oriY,oriZ})
Features Quaternion to Euler Angles
Parameter Quaternion
Return
Euler angles (in radians) after conversion from quaternions of parameters
Value
pentagram.aubo
--set tool parms
set_tool_kinematics_param({0.000000, 0.000000, 0.200000}, {1.000000, 0.000000,
0.000000, 0.000000})
set_tool_dynamics_param(0, {0, 0, 0}, {0, 0, 0, 0, 0, 0})
--move to A
move_joint({0.060122, 0.132902, -1.060100, 0.377794, -1.570797, 0.060117}, true)
while (true) do
--move to C
set_relative_offset({0.2, 0, 0}, rpy2quaternion({d2r(0), d2r(0), d2r(36 - 180)}),
{0.000000, 0.000000, 0.000000}, {1.000000, 0.000000, 0.000000, 0.000000})
move_line(get_global_variable("Realtime_Waypoint"), true)
--move to D
set_relative_offset({0.2, 0, 0}, rpy2quaternion({d2r(0), d2r(0), d2r(36)}),
{0.000000, 0.000000, 0.000000}, {1.000000, 0.000000, 0.000000, 0.000000})
move_line(get_global_variable("Realtime_Waypoint"), true)
--move to E
set_relative_offset({-0.2, 0, 0}, rpy2quaternion({d2r(0), d2r(0), d2r(36)}),
{0.000000, 0.000000, 0.000000}, {1.000000, 0.000000, 0.000000, 0.000000})
move_line(get_global_variable("Realtime_Waypoint"), true)
--move to A
set_relative_offset({0.2, 0, 0}, rpy2quaternion({d2r(0), d2r(0), d2r(36)}),
{0.000000, 0.000000, 0.000000}, {1.000000, 0.000000, 0.000000, 0.000000})
move_line(get_global_variable("Realtime_Waypoint"), true)
end
{
"pos" = {
"x" = posX
"y" = posY
"z" = posZ
}
"ori" = {
"w" = oriW
void add_waypoint(
{double joint1Angle, double joint2Angle, double joint3Angle,
double joint4Angle, double joint5Angle, double joint6Angle}
)
Features Add waypoints to the list of global waypoints, serving the move_track function
Parameter Type table
Return N/A
Instructions add_waypoint ({-0.000003, -0.127267, -1.321122, 0.376934, -1.570796, -0.000008})
void clear_global_waypoint_list(void)
Features Clear the global waypoint list
Parameter N/A
Return N/A
clear_global_waypoint_list()
Instructions Note: When using move_track multiple times, you need to clear the last trajectory
point
--init var
offset = 0
direction = 1 -- 1:Forward -1:Reverse
while (true) do
--Move to the first track point
init_global_move_profile()
set_end_maxvelc(1.000000)
set_end_maxacc(1.000000)
set_relative_offset({offset * 0.05, 0, 0}, CoordCalibrateMethod.zOzy, {-0.000003,
-0.127267, -1.321122, 0.376934, -1.570796, -0.000008}, {-0.244530, -0.169460,
-1.356026, 0.384230, -1.570794, -0.244535}, {-0.196001, 0.070752, -1.129614,
0.370431, -1.570795, -0.196006}, {0.111100, 0.222000, 0.333000})
move_line({0.208890, -0.044775, -1.246891, 0.368688, -1.570800, 0.208869}, true)
--Move cir
init_global_move_profile()
set_end_maxvelc(1.000000)
set_end_maxacc(1.000000)
set_relative_offset({offset * 0.05, 0, 0}, CoordCalibrateMethod.zOzy, {-0.000003,
-0.127267, -1.321122, 0.376934, -1.570796, -0.000008}, {-0.244530, -0.169460,
-1.356026, 0.384230, -1.570794, -0.244535}, {-0.196001, 0.070752, -1.129614,
0.370431, -1.570795, -0.196006}, {0.111100, 0.222000, 0.333000})
add_waypoint({0.208890, -0.044775, -1.246891, 0.368688, -1.570800, 0.208869})
add_waypoint({-0.237646, -0.169014, -1.355669, 0.384145, -1.570793, -0.237655})
add_waypoint({-0.000009, 0.087939, -1.110852, 0.372015, -1.570793, -0.000007})
set_circular_loop_times(0)
move_track(MoveTrackType.ARC_CIR, true)
end
void set_tool_kinematics_param(
{double posX, double posY, double posZ}, {double oriW = 1,double oriX = 0, double
oriX = 0, double oriX = 0}
)
void set_tool_dynamics_param(
double payload,
{double gravityCenterX, double gravityCenterY, double gravityCenterZ},
{double inertiaXX = 0, double inertiaXY = 0, double inertiaXZ = 0, double inertiaYY = 0,
double inertiaYZ = 0, double inertiaZZ = 0})
Set tool dynamics parameters, load and center of gravity xyz must be passed, inertia
Features
can be skipped
Payload-load unit kg
Parameter Center of gravity-table
Inertia-table
Return N/A
Instructions set_tool_kinematics_param(3,{0.1,0.2,0.3})
void robot_pause(void)
Features Robotic arm paused. It can only be called if and only if the arm is in motion.
Parameter N/A
Return N/A
Instructions robot_pause()
void robot_continue(void)
The arm resumes motion. It can only be called if and only if the arm is in the paused
Features
state.
Parameter N/A
Return N/A
Instructions robot_continue()
void robot_slow_stop(void)
void robot_fast_stop(void)
Features Arm fast stop. It can only be called if and only if the arm is in motion.
Parameter N/A
Return N/A
Instructions robot_fast_stop()
8 Internal Modules
Note: The IO name refers to the chapter “Control cabinet standard IO name”
void set_robot_io_status(RobotIOType ioType, string name, double value)
Features Set the robot body IO status
ioType Indicates the IO type. Refer to the above for the enumerated type.
Parameter name Indicates IO name, string type
value IO state value, double type
Return N/A
Instructions Robot body standard IO name please refer to teach pendant V4 version IO setting
interface
Example set_robot_io_status (RobotIOType.RobotBoardUserDI," U_DO_00",1)
Note: A special real-time waypoint variable is built into the teach pendant named
"Realtime_Waypoint".
This variable is only allowed to obtain information. Get the real-time waypoint information of the
current robot arm by the following call form. get_global_variable("Realtime_Waypoint")
The return value is the joint angle of the current real-time waypoint {joint1Angle, joint2Angle,
Operation method:
The example is divided into two script files: move_control.aubo and tcp_server.aubo.
You need to add variables V_D_posX, V_D_posY, V_D_posZ in the variable
configuration interface. Then create a new project in the teach pendant,
move_control.aubo is embedded into the main program as a script file, and
tcp_server.aubo is embedded into the Thread as a script file. Before running, you
need to run the project first (the purpose is to start the TCP Server first), and then
send the string "posX,posY,posZ" to the teach pendant through the TCP Client. The
source code is as follows:
move_control.aubo
init_global_move_profile()
set_joint_maxvelc({1.298089,1.298089,1.298089,1.555088,1.555088,1.555088})
set_joint_maxacc({8.654390,8.654390,8.654390,10.368128,10.368128,10.368128})
move_joint({-0.000003, -0.127267, -1.321122, 0.376934, -1.570796, -0.000008},
true)
while (true) do
move_joint(get_target_pose({get_global_variable("V_D_posX"),
get_global_variable("V_D_posY"), get_global_variable("V_D_posZ")}, false), true)
end
local result = {}
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
port = 6666
ip = "127.0.0.1"
initTCPServer(port)
set_global_variable("V_D_posX", -0.400319)
set_global_variable("V_D_posY", -0.121499)
set_global_variable("V_D_posZ", 0.547598)
recv = ""
while(recv ~= "quit") do
sleep(0.02)
recv=serverRecvData(ip)
if (recv~="") then
data = string.split(recv, ",")
set_global_variable("V_D_posX", tonumber(data[1]))
set_global_variable("V_D_posY", tonumber(data[2]))
set_global_variable("V_D_posZ", tonumber(data[3]))
end
end
Example:
strcmp(s1,s2) -- Before calling the strcmp() function, you must evaluate the input
string as a null value! , if str1==str2, then return zero; if str1>str2,
then return positive number; if str1<str2, then return negative
array = {"Lua", "Tutorial”} --lua array starts from first
for i= 1, 2 do
print(array[i])
end
--output :
Lua
Tutorial--]]
array = {}
for i=1,3 do
array[i] = {}
for j=1,3 do
array[i][j] = i*j
end
end
Functional description:
The example is divided into two parts, one for each thread, the main thread for motion control,
and the child thread for TCP data interaction.
Obtain data from the TCP Server through the child thread in real time, the parameters are
exchanged with the main thread through the global variables of the teach pendant after
unpacking and parsing.
In this example, the data exchange between the two threads is completed by two variables
V_B_run and V_I_offset.
The child thread first connects to the TCP Server, and the teach pendant acts as the TCP Client.
After the connection is successful, the data is read cyclically. The data format is "run, offset", run
represents the lifting of the blocking wait for the main thread, and offset represents the offset of
the arc movement of the track in the main thread.
For example, to send "run, 1" from the TCP Server to the client, after unpacking, the V_B_run
assignment is true, V_I_offset assignment is 1. The main thread wait condition judgment is
satisfied, exit wait, start the movement, first move to the arc of the first track One way point,
The circular movement is then performed with respect to the presentation offset V_I_offset of
the waypoint in the user coordinate system. Because the relative offset is used here, the start
point of each arc motion is different. Therefore, the same relative offset parameter needs to be
used in the preparation point of the linear motion to the arc path configured before the arc
motion. Make sure that you have reached the preparation point for the trajectory before each arc
movement.
Operation method:
The example is divided into two script files father.aubo and child.aubo. A new project needs to
be created in the teach pendant, father.aubo is embedded in the main program, and child.aubo
is embedded in the Thread. Before running, you need to start TCP Server (pay attention to modify
IP and port), and then send the string "run, offset" to the teach pendant through TCP Server. The
source code is as follows:
init_global_variables("V_B_run,V_I_offset")
--move to readypoint
init_global_move_profile()
set_joint_maxvelc({1.298089,1.298089,1.298089,1.555088,1.555088,1.555088})
set_joint_maxacc({8.654390,8.654390,8.654390,10.368128,10.368128,10.368128})
move_joint(get_target_pose({-0.400320, -0.209060, 0.547595},
rpy2quaternion({d2r(-179.999588), d2r(0.000243), d2r(-89.998825)}), false, {0.0,
0.0, 0.0}, {1.0, 0.0, 0.0, 0.0}), true)
while (true) do
sleep(0.001)
while (not (get_global_variable("V_B_run"))) do
sleep(0.01)
end
local loop_times_flag_0 = 0
while (loop_times_flag_0 < 1) do
loop_times_flag_0 = loop_times_flag_0 + 1
sleep(0.001)
--move arc
init_global_move_profile()
set_end_maxvelc(1.000000)
©2015-2021 AUBO all rights reserved 55 V4.5.4
set_end_maxacc(1.000000)
set_relative_offset({get_global_variable("V_I_offset") * 0.05, 0, 0},
CoordCalibrateMethod.zOzy, {-0.000003, -0.127267, -1.321122, 0.376934,
-1.570796, -0.000008}, {-0.244530, -0.169460, -1.356026, 0.384230, -1.570794,
-0.244535}, {-0.196001, 0.070752, -1.129614, 0.370431, -1.570795, -0.196006},
{0.100000, 0.200000, 0.300000})
add_waypoint({0.208890, -0.044775, -1.246891, 0.368688, -1.570800,
0.208869})
add_waypoint({-0.237646, -0.169014, -1.355669, 0.384145, -1.570793,
-0.237655})
add_waypoint({-0.000009, 0.087939, -1.110852, 0.372015, -1.570793,
-0.000007})
set_circular_loop_times(0)
move_track(MoveTrackType.ARC_CIR, true)
end
set_global_variable("V_B_run", false)
end
child.aubo
--child thread
function string.split(str, delimiter)
if str==nil or str=='' or delimiter==nil then
return nil
end
local result = {}
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
--read data
recv=""
while(true) do
V4.5.4 56 ©2015-2021 AUBO all rights reserved
sleep(1)
recv=clientRecvData(ip)
print(recv)
if (recv~="") then
table1 = string.split(recv, ",")
if (table1[1]=="run") then
set_global_variable("V_I_offset", tonumber(table1[2]))
set_global_variable("V_B_run", true)
end
end
end