当前位置:网站首页>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)
边栏推荐
- PancakeSwap技术:夹子机器人系统开发原理
- MySQL foundation - multi table query
- 疫情居家外包项目之协作开发| 社区征文
- Problem solving metauniverse, multi communication scheme in online games
- C winfrom chart chart control bar chart and line chart
- controller、service、dao之间的关系
- InheritableThreadLocal 在线程池中进行父子线程间消息传递出现消息丢失的解析
- Practice | extreme optimization of script errors - make script errors clear at a glance
- PHP delete directory
- Naacl 2022 | distillation of machinetranslation SOTA model
猜你喜欢

Word2vec vector model of Wiki Chinese corpus based on deep learning

解题元宇宙,网络游戏中的多元通信方案

腾讯云发布自动化交付和运维产品Orbit,推动企业应用全面云原生化

Shenzhen internal promotion | Shenzhen Institute of computing science recruits assistant machine learning Engineer (school recruitment)

Inheritablethreadlocal resolves message loss during message transmission between parent and child threads in the thread pool

最高81.98%!超百所“双一流”高校本科深造率公布

Mathematical knowledge: finding combinatorial number II - finding combinatorial number
![[untitled]](/img/e2/be57a7e22275af59183c50e0710837.png)
[untitled]

Comprehensive analysis of Seata distributed transaction at and XA

研究所的这些优势真香!上岸率还极高!
随机推荐
知道创宇为能源行业资产管理助力,入选工信部2021物联网示范项目
【南京大学】考研初试复试资料分享
LSB hidden items of stream carrier based on assembly implementation
curl: (56) Recv failure: Connection reset by peer
KUKA子程序/函数怎么建立和使用方法
深圳内推 | 深圳计算科学研究院招聘机器学习助理工程师(校招)
关于XAMPP无法启动mysql数据库
Fluent的msh格式网格学习
Basics | draw arcs in the physics engine
Kali installation tutorial 2020
Implement a ThreadLocal by yourself
在线文本数字识别列表求和工具
ICML 2022 | 基于解耦梯度优化的可迁移模仿学习方法
第42期:MySQL 是否有必要多列分区
Help MySQL data analysis with databend
反射
Perhaps in two years, ASML will be free to supply EUV lithography machines to China
C comparison of the performance of dapper efcore sqlsugar FreeSQL hisql sqlserver, an ORM framework at home and abroad
从居家办公中感悟适配器模式 | 社区征文
Function calculation asynchronous task capability introduction - task trigger de duplication