Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IF else commands in Robodk
#1
Hello RDK People

Im really new in roboDK. Regarding that i have maybe a really "stupid" question, but i havent found a soultion from robodk help to solve it .

I have made 2 diffrent movement programs in robodk. Let´s call them Prog1 and Prog 2.
Now i want make condition if and else.
How i can do it in RoboDK ?

I can generate main program, that will run first Prog1 then Prog2, and edit it by hand and add the conditions.
Like that, but i hope RoboDK has better solution inside the program how to do it
Code:
%%%
VERSION:1
LANGUAGE:ENGLISH
%%%

MODULE MOD_MainProgram

PERS tooldata rdkTool := [TRUE,[[0,0,0],[1,0,0,0]],[20,[0,0,200],[1,0,0,0],0,0,0.005]];

PROC MainProgram()
!Program generated by RoboDK v5.2.1 for ABB IRB 6400 2.8 120 on 11/02/2021 20:34:18
!Using nominal kinematics.
if andur_1=HIGH THEN
Prog1;
else
Prog2;
ENDIF
ENDPROC

PROC Prog1()
MoveJ [[2145.000,0.000,1143.934],[0.70710678,0.00000000,0.70710678,0.00000000],[0,-1,-1,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
MoveJ [[2145.000,870.641,1143.934],[0.70710678,0.00000000,0.70710678,-0.00000001],[0,0,-1,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
MoveJ [[2145.000,870.641,1981.626],[0.70710678,0.00000000,0.70710678,0.00000000],[0,0,-1,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
MoveJ [[2145.000,3.905,1981.626],[0.70710678,-0.00000001,0.70710678,0.00000000],[0,0,-1,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
MoveJ [[2145.000,889.036,1158.989],[0.70710678,-0.00000001,0.70710678,0.00000000],[0,0,-1,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
ENDPROC

PROC Prog2()
MoveJ [[2145.000,0.000,2075.000],[0.70710678,-0.00000001,0.70710678,0.00000000],[0,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
MoveJ [[2145.000,41.161,2382.972],[0.70710678,0.00000000,0.70710678,0.00000000],[0,1,-2,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
MoveJ [[2145.000,695.675,2382.972],[0.70710678,0.00000000,0.70710678,0.00000000],[0,1,-2,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
MoveJ [[2145.000,695.675,2135.282],[0.70710678,-0.00000001,0.70710678,0.00000000],[0,1,-2,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
MoveL [[2145.000,55.244,2135.282],[0.70710678,0.00000001,0.70710678,0.00000001],[0,1,-2,1],[9E9,9E9,9E9,9E9,9E9,9E9]], v200, fine, rdkTool;
ENDPROC

ENDMODULE

.
#2
If/then/else statements are not supported when you use the UI. Your workaround is the best way to go unless you want to use the API. For example, you could write a small script that emulates your logic and triggers the corresponding program.

I'm sorry we can't be of more help at this moment.
#3
Hi,

If you download the latest version of RoboDK, you can use "IF" and "WHILE" statement.

For it to work, you need to activate "Flow control statement" in "Tools"->"Options"->"Station"

I attached an example station.
Let us know if you have any comments.

Jeremy


Attached Files
.rdk FlowControlStatements.rdk(Size: 1.11 MB / Downloads: 497)
找到有用的信息关于RoboDK及其特点res by visiting our2022世界杯32强赛程表时间 and by watching tutorials on ourYoutube Channel.


#4
Dear Jeremy,


My colleague tried a project using "IF" and "WHILE" statements, but he found something wrong in his project as attached.

Could you specify what the cause is about not working well IF statement in his project?

Best Regards,
Hiroe


Attached Files
.zip sample (1).zip(Size: 3.18 MB / Downloads: 243)
#5
For it to work, you need to activate "Flow control statement" in "Tools"->"Options"->"Station".

I forgot to mention it in my first comment, I edited it.
找到有用的信息关于RoboDK及其特点res by visiting our2022世界杯32强赛程表时间 and by watching tutorials on ourYoutube Channel.


#6
Hi Jeremy

Is there a reason why theFlow control statementis not enabled by default ?
#7
Flow control statements in RoboDK is an experimental feature. To properly support this feature we would have to improve all our post processors to properly generate these flow control statements when generating robot programs.




Users browsing this thread:
1 Guest(s)