RoboDK Forum
IF else commands in Robodk- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: IF else commands in Robodk (/Thread-IF-else-commands-in-Robodk)



IF else commands in Robodk-kri5too-02-12-2021

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

珀耳斯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

.



RE: IF else commands in Robodk-Albert-02-12-2021

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.


RE: IF else commands in Robodk-Jeremy-03-31-2021

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


RE: IF else commands in Robodk-Hiroe-07-01-2021

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


RE: IF else commands in Robodk-Jeremy-07-02-2021

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.


RE: IF else commands in Robodk-malacasse-03-04-2022

Hi Jeremy

Is there a reason why theFlow control statementis not enabled by default ?


RE: IF else commands in Robodk-Albert-03-06-2022

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.