Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

KUKA KRL in python

#1
Dear forum users,

I wonder if there is a possibility to include KUKA KRL code within my python script. With KRL i would write:BAS( #TOOL ,2) to activate Tool2. Now I wonder how to activate tools with the RoboDK API?

I tried to think of a workaround. I wanted to create a KUKA program within the Python script, pass the KRL command and run the program. That didn't work. Maybe I faulty interpreted the AddProgram()-function. Those are the few lines I have tried within my python script:

prog = RDK.AddProgram('Set_Tool_Program')
prog.RunInstruction('BAS(#TOOL,2)',INSTRUCTION_INSERT_CODE)
prog.RunCode()
prog.WaitFinished()


Does anybody know how to incorporate the KRL "BAS(#TOOL,2)" command into my python script?

Thank you in advance!
#2
[attachment=1670 Wrote:KatCla pid='7083' dateline='1607094418']Dear forum users,

I wonder if there is a possibility to include KUKA KRL code within my python script. With KRL i would write:BAS( #TOOL ,2) to activate Tool2. Now I wonder how to activate tools with the RoboDK API?

I tried to think of a workaround. I wanted to create a KUKA program within the Python script, pass the KRL command and run the program. That didn't work. Maybe I faulty interpreted the AddProgram()-function. Those are the few lines I have tried within my python script:

prog = RDK.AddProgram('Set_Tool_Program')
prog.RunInstruction('BAS(#TOOL,2)',INSTRUCTION_INSERT_CODE)
prog.RunCode()
prog.WaitFinished()


Does anybody know how to incorporate the KRL "BAS(#TOOL,2)" command into my python script?

Thank you in advance!

Hello everyone,

i could get my python script to run. To creat and run the program I used the following lines:

RDK。AddProgram(“设置_Tool_Program')
prog=RDK.Item('Set_Tool_Program',ITEM_TYPE_PROGRAM)
prog.RunInstruction('BAS(#TOOL,2)',INSTRUCTION_INSERT_CODE)
cnt=prog.RunCode()
prog.WaitFinished()
print(cnt)

Since my program includes just one command (to change the active tool), and the function RunCode() returns 1, I asume that theoretically the instruction shoud be executed successfully. But practically it is not executed, because my active tool is still the same.


现在我想问湿草地类型的指令可以公关ograms in the project tree execute?
A snipped of the program in the porject tree is attached.


I am glad for any help!


Attached Files Image(s)

#3
I assume you are using the robot driver. Custom instructions are not supported using the driver with most robot controllers.

However, you can customize a program calls trigger in your RoboDKSync file as explained here:
//www.sinclairbody.com/forum/Thread-Program-...29#pid4529

So you could link a program call such as Program(2) to BAS(#TOOL,2).
#4
[attachment=1705 Wrote:Albert pid='7211' dateline='1607963965']I assume you are using the robot driver. Custom instructions are not supported using the driver with most robot controllers.

However, you can customize a program calls trigger in your RoboDKSync file as explained here:
//www.sinclairbody.com/forum/Thread-Program-...29#pid4529

So you could link a program call such as Program(2) to BAS(#TOOL,2).

Dear Albert,

thank you very much for your reply!

I am not entirely sure if I understood you correctly, but I changed the RoboDKSync file as seen in the attachement.
With my python script I tried to run the "RunCodeCustom" command, but I am not sure how to pass the program ID so that the correct CASE within the Sync file is chosen.

According to your suggested thread I tried it like:
robot.RunCodeCustom("Program 2",INSTRUCTION_CALL_PROGRAM)
in order to enter CASE 2.

That does not work. So It seems like I am programming nonsense again.
Could you please help me with passing the program id, in order to choose the right CASE within the Sync file? Or to clear my misunderstandings?

Thank you very much!


Attached Files Thumbnail(s)

#5
Can you try calling RunInstruction instead of RunCodeCustom?

For example:
Code:
robot.RunInstruction("Program 2",INSTRUCTION_CALL_PROGRAM)

This should enter CASE2. Keep in mind this Switch case is inside another switch case.
#6
(12-26-2020, 03:00 PM)Albert Wrote:Can you try calling RunInstruction instead of RunCodeCustom?

For example:
Code:
robot.RunInstruction("Program 2",INSTRUCTION_CALL_PROGRAM)

This should enter CASE2. Keep in mind this Switch case is inside another switch case.

Hello Albert,
thank you again for your reply!

I will try your suggestion. Thank you!

To clear misunderstandings: You have mentioned in a different thread that I can not trigger programs by name, so "Program 2" is the fixed syntax? I do not have to adapt the "Program" ? Just the following integer, depending on what case to enter? My RoboDKSync file is the default file. Do I have to adapt anything else?

What do you mean by "this switch case is inside another switch case"? Do I have to set the according case (case 13 => COM_ACTION = 13) of the outer (first) switch case myself? In my understanding: The call of "RunInstruction(program_id, ...)" triggers (enters) the 13th case of the first switch case and with the program_id I choose the case of the second switch case. Isn't it like that?

Thank you for your help!




Users browsing this thread:
1 Guest(s)