当前位置:网站首页>How to establish and use KUKA subroutines / functions
How to establish and use KUKA subroutines / functions
2022-06-29 17:09:00 【User 4442670】
HI Hello, everyone , It's time for small farmers to talk about robots . Some time ago, some people reported that small farmers are getting lazier and lazier , Twitter doesn't write technical articles anymore . I am very ashamed to hear that . So today we must have something without any technical content .
kuka
Subroutines and functions
Any programming ape should have learned what subroutines and functions are before losing his hair . In the field of robotics, the concept is not so clear ,kuka Any program in the robot can call other programs , Or here we call it module , Programmers can set a module as the main program , Even if his name is subroutine .
Of course, it also distinguishes between global subroutines and local subroutines
As the name suggests, the global subroutine is a program that anyone can call .
A part is a program written under a module , It's called a local subroutine , This program can only be used under this module .
Then the function here can be called a function block , It is a function block that cannot execute motion instructions and cannot run alone . Or simply call it function . It has no dat file , And there will be a return value to the program that calls it .
Of course, it is also divided into global functions and local functions .
1
Subroutines / function
DEF mainPROG( )
; This is the main program
...
END
_______________________________________
DEF PROG1( )
; This is a local subroutine 1
...
END
_______________________________________
DEF PROG2( )
; This is a local subroutine 2
...
END
_______________________________________
DEF PROG3( )
; This is a local subroutine 3
...
ENDLet's first look at the local subroutines , Write in the module END Line is followed by the local subroutine , Subroutines can be called by the main program in the whole file . And they can call each other . You can also pass parameters .
Let's take a look at the fact that a local function is in DEF Add... To the back FCT, And give the return type of this function . You can think of it as a variable that can operate .
Because you need to use a variable of the same type to receive its return value
DEF mainPROG( )
; This is the main program
INT I
I = PROG2( )
END
_______________________________________
DEFFCT BOOL PROG1( )
; This is a local subroutine 1
...
ENDFCT
_______________________________________
DEFFCT INT PROG2( )
; This is a local subroutine 2
...
ENDFCT
_______________________________________
DEFFCT REAL PROG3( )
; This is a local subroutine 3
...
ENDFCTAfter knowing the local subroutine, it is easy to think of the global subroutine . Take each independent module directly as a subroutine
DEF Subroutines ( )
; This is the main program
The main program ( )
ENDDEF The main program ( )
; This is a subroutine
ENDSo the global subroutine can be called freely . So look at the global functions
DEF MAINPROG( )
BOOL B1
B1 = FUNC1( )
ENDDEFFCT BOOL FUNC1()
ENDFCT1
Use of subroutines and functions
It seems that many friends prefer example demonstration , So I don't say much , Go straight up
DEF MAIN1( )
; This is a camera capture process
PTP HOME
LOOP ; Main circulation
PICK1(); Call the crawler 1
DROP1(); Call the placer 1
PICK2(); Call the crawler 2
DROP1(); Call the placer 1
ENDLOOP
ENDDEF PICK1( )
; This is the crawl program 1
PTP P1
POS_N = CAMERA(1); Call the camera to take photos , Pass in the camera program number , Return location information
XPN = PDAT(POS_N); Call the calculator , Pass in the location information obtained by the camera , Return to xpn
PTP XPN; Run to the xpn( Where the calculation is completed ) Carry out crawling work
GRIP(#CLO)
...
END ; Return to the main program after completion
_______________________________________
DEFFCT POS PDAT(N); The calculation of each program is different, so the local ...
P.X = N.X + P.X
P.Y = N.Y + P.Y
P.Z = N.Z + P.Z
P.A = N.A + P.A
P.B = N.B + P.B
P.C = N.C + P.C
RETURN P
ENDFCTDEF PICK2( )
; This is the crawl program 2
PTP P1
POS_N = CAMERA(2); Call the camera to take photos , Pass in the camera program number , Return location information
XPN = PDAT(POS_N); Call the calculator , Pass in the location information obtained by the camera , Return to xpn
PTP XPN; Run to the xpn( Where the calculation is completed ) Carry out crawling work
GRIP(#CLO)
...
END ; Return to the main program after completion
_______________________________________
DEFFCT POS PDAT( ); The calculation of each program is different, so the local
...
RETURN P
ENDFCTDEF DROP1()
; This is the placement program 1
PTP P1
XPN = DDAT( ) Calculate the amount of cheap money placed according to the price obtained by grabbing
PTP XPN
GRIP(#OPN)
...
END ; After placing, return to the main program
_______________________________________
DEFFCT POS DDAT( ); The calculation of each program is different, so the local
...
RETURN P
ENDFCTDEFFCT POS CAMERA(N:IN); It is used by more programs, so it is established as a global
; This is the camera trigger program
$OUT[N] = TRUE
WAIT FOR $IN[N]==TRUE
RETURN SIGNAL_N
ENDFCTDEF GRIP(N:IN)
SWITCH N
CASE #OPN
OPEN( )
CASE #CLO
CLOS( )
ENDSWITCH
END
DEF OPEN( )
$OUT[2]=TRUE
WAIT FOR $IN[2]
END
DEF CLOS( )
$OUT[2]=FALSE
WAIT FOR NOT $IN[2]
END
1
Program explanation
I wrote a lot of code , But smart you should be able to see that this is a program framework , So how to explain it? Let's see
in addition KUKA There are many system functions , These functions do not require us to write , Just use it directly
The absolute value ABS(x)
root SQRT(x)
sine SIN(x)
cosine COS(x)
tangent TAN(x)
Arccosine ACOS(x)
Anyway ATAN2(y,x)
Determine the string length when declaring StrDeclLen(x)
Length of string variable after initialization StrLen(x)
Delete the contents of string variables StrClear(x)
Extended string variables StrAdd(x,y)
Compare the contents of string variables StrComp( x,y,z)
Copy string variables StrCopy(x,y)
Generate information Set_KrlMsg(a,b,c,d)
Generate dialogue Set_KrlDLg(a,b,c,d)
Check information Exists_KrlMsg(a)
Check dialogue Exists_KrlDlg(a,b)
Delete the information Clear_KrlMsg(a)
Read information buffer Get_MsgBuffer(a)
边栏推荐
- iNFTnews | Meta在元宇宙中的后续计划会是什么?
- 从Mpx资源构建优化看splitChunks代码分割
- MySQL highly available cluster – MHA
- Actual combat | magical conic gradient
- 0基础自学STM32(野火)——寄存器点亮LED
- Redis bloom filter and cuckoo filter
- Kali installation tutorial 2020
- AI and creativity
- Paper notes: e (n) equivariant graph neural networks
- 疫情居家外包项目之协作开发| 社区征文
猜你喜欢

【南京大学】考研初试复试资料分享

After eight years of testing and opening experience and interview with 28K company, hematemesis sorted out high-frequency interview questions and answers

MySQL foundation - multi table query

mysql数据库扫盲,你真的知道什么是数据库嘛

A simple but scalable feature normalization method

Perhaps in two years, ASML will be free to supply EUV lithography machines to China

Take another picture of cloud redis' improvement path

Étalonnage de la caméra monoculaire et de la caméra binoculaire à l'aide de l'outil d'étalonnage kalibr

手把手教你在windows上安装mysql8.0最新版本数据库,保姆级教学

A user level thread library based on C language
随机推荐
Gradle下载慢或无法下载
SpingMVC请求和响应
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
手把手教你在windows上安装mysql8.0最新版本数据库,保姆级教学
MySQL highly available cluster – MHA
Basics | draw arcs in the physics engine
Mathematical knowledge: finding combinatorial number II - finding combinatorial number
【R语言数据科学】:文本挖掘(以特朗普推文数据为例)
2022年软件评测师考试大纲
epoll分析
Help MySQL data analysis with databend
知道创宇为能源行业资产管理助力,入选工信部2021物联网示范项目
What is the follow-up plan of infotnews | meta in the metauniverse?
windows平台下的mysql启动等基本操作
@Component与@Configuration区别
Graduates are confused and middle-aged people are anxious. How can the career path become wider and wider?
机器学习8-人工神经网络
Shenzhen internal promotion | Shenzhen Institute of computing science recruits assistant machine learning Engineer (school recruitment)
最高81.98%!超百所“双一流”高校本科深造率公布
Practice | extreme optimization of script errors - make script errors clear at a glance