Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python: Specific post processor and run mode for machining project
#1
Hi,
I am using a Python script to generate a 3D-printing project. As of yet I have not figured out how to use the ProgramStart, AddProgram, RunCode or MakeProgram methods correctly. The procedure is roughly this:
- user is prompted to choose a geometry file
- object is loaded into RoboDK using

Code:
PrintPart=RDK.AddFile(GeomFile, parent=frame)
- a machining project is added using

Code:
PrintProject=RDK.AddMachiningProject(name,robot)
- the object is added to the machining project:

Code:
PrintProject.setMachiningParameters(part=PrintPart)
This way the printing object is attached to the machining project and RoboDK automatically generates a RoboDK-program. So far so good.
I would now like to translate the RoboDK program into a real robot program. This raises two questions.
1) How can I do this, using a specific post processor?
I am currently using MakeProgram to save the robot program to a folder. This works but is not satisfying, because it uses the KRC2 post processor per default. I need to use another one.
2) I actually do not want to safe the program to a folder, so MakeProgram could be entirely wrong. I would either like to
a) send the program to and run it on the robot. This should refer to RunMode = 6 as I understand it. Or
b) send the program to and run it on the robot independently from RoboDK and the laptop. This should be RunMode = 5 if I got that right.

Please let me know if I left out any crucial information. I can not see which method to use to achieve these goals.
I already tried ProgramStart as it is shown in the API documentation, but it does not seem to work for the automatically generated printing program. On the other side it seems to be the only method that allows me to choose the post processor.
Any advice where to go from here is appreciated.

Best regards
David
#2
Hi David,

It is not possible to create a 3D print project through the API. We'll try to add this as a new feature in a timely manner. At this moment, the following call creates a curve follow project or a point follow project if the object has curves or points:
PrintProject.setMachiningParameters(part=PrintPart)

To specify the robot post processor you can change the post processor manually (right click the program and select Select Post processor) and save the project. In that case, it will use the last post processor selected.

You can also specify the robot post processor usingProgramStart. For example:
RDK.ProgramStart('ProgramName','C:/MyProgramFolder/', "KUKA_KRC4", robot)
However, this assumes you are generating the program directly from Python (not using MakeProgram). In the worst case, with the current version you can generate a dummy/empty program to change the post processor if you don't want to do it manually (post processor settings are stored in the RDK files and robot files).

If you have your path/machining project ready you can do the following to generate a program and send it to the robot automatically:

update_result = PrintProject.Update()
程序= PrintProject.getLink(ITEM_TYPE_PROGRAM)
run_mode = RUNMODE_MAKE_ROBOTPROG_AND_UPLOAD
program.MakeProgram(path_folder, run_mode)

This is the same as right clicking your program and selecting "Send Program to Robot".
#3
Hi Albert,
thanks for your explanations. You are right, I have not been completely accurate there, what I meant is a follow point project.
However, selecting a post processor manually is not an option. I have to use the API. Your suggestion to create a dummy program in order to change the settings for the robot sounds fair to me. Sadly it does not seem to work the way I tried it (see attachment).
The script opens RoboDK, adds my robot and creates an empty program in the folder of my choice. That is all fine,
but if I check the settings of the robot it still uses the KRC2 post processor.
Can you tell me what is wrong with my procedure?


Attached Files
.py Command_tester.py(Size: 615 bytes / Downloads: 496)
#4
Hi David,
There is a new update available since yesterday that will allow you to only change the post processor. You should usesetParam. For example:

Code:
机器人。setParam("PostProcessor", "KUKA_KRC4")
You can take the latest version here:
//www.sinclairbody.com/downloads/Win64
#5
That is just perfect, thank you very much!
#6
Hi,
I would like to get back to this topic once more. My actual question is still about the transfer of the program to the robot. To make things maybe a little clearer let me begin with the situation as it is.
The program for the machining project is ready in RoboDK. Since I am using it for 3D printing I used the recommended Slic3r-Software to generate the path and also the printing parameters. What is still causing difficulties are the Extruder() calls (see attachment). As of yet they are included in the RoboDK program as program calls but they are skipped when the program is running since there are no sub programs named Extruder(2.000), Extruder(2.011), Extruder(2.064) and so on. I need to translate the extruder values to I/O-values so they can be transferred to my printing equipment.

I can think of two (reasonable) ways to do that and would like to know if that is possible. The major difference between both options is the way the program is transferred to the robot.

1) I could write a script that loops through the entire program in RoboDK, retrieves each extruder call and replaces it by I/O instructions. That should be possible right?
Then I would use

Code:
program.setRunType(PROGRAM_RUN_ON_ROBOT)
and execute the program on the robot using the KUKAVARPROXY, assuming that it supports not only robot movement but also I/O instructions.
This is really not my preferred option since it would most probably take a lot of time to loop through the program and replace every extruder call. My test object is quite small but already has like 370k lines of instructions. I prefer option 2).

2) I customise the post processor in an appropriate way, which I already tried and which seems much more sophisticated to me. Similar to what Albert suggested,
Quote: run_mode = RUNMODE_MAKE_ROBOTPROG_AND_UPLOAD

program.MakeProgram(path_folder, run_mode)
I would then use

Code:
run_mode = RUNMODE_MAKE_ROBOTPROG_AND_START # run_mode = 5
program.MakeProgram(path_folder, run_mode)
to transfer the program to the robot and execute it there.
That would be the best solution, although there are a few things left unclear. What do I have to consider when choosing the path_folder? I assume I have to use the ftp-settings to access the robot controller, but where do I have to put the program then? Do you have experience with this method and a KRC4 controller or maybe even a sample program? I am asking in advance before trying it out because several other boards that are dealing with KUKA are stating that it is somewhere between difficult and impossible what I need to do. According to other users the file transfer is possible with some restraints but remotely starting a program is considered impossible due to safety issues. Anyway, I would gladly prove them all wrong if it is possible with RoboDK.

To sum it up, I need to:
- revise my program either using a script or a customised post processer (that is not the problem)
- transfer the program to the robot
- execute the program on the robot (automatically)

I hope there is a solution to that and I am grateful for help and support.


Attached Files Thumbnail(s)

#7
I recommend you to apply the following modifications to take the Extruder calls into account:

1- For offline programming:
Our latest KUKA KRC2 post processor (default post used for KUKA robots, attached) takes the Extruder commands into account and can easily be customized in the post processor. I recommend you to take a look at the configurable section of the file (around line 75) and how the RunCode parses the Extruder call (line 631).

我强烈建议你重命名post processor if you customize it because a new RoboDK install will override this file.

2- For online programming:
RoboDK doesn't support calling named subprograms using the driver (Run On Robot option). However, there is a workaround for this and you can call numbered programs. To do so, you have to trigger a program a program call with a number. Using the GUI or the API. An example using the API would be:
机器人。RunCodeCustom(“职业gram 5", INSTRUCTION_CALL_PROGRAM)

To integrate this with the Extruder command you can add a new Python program in your RoboDK project called Extruder, then parse the passed parameter using sys.argv (similar to the RoboDK/Library/Macros/ArcOn.py example).

This is what the RoboDKSync.src file looks like towards the end. You can customize the action once a program is triggered by retrieve the program id. You could actually use the passed parameter as the E value (program id).

Code:
CASE 13
;----- Run program COM_VALUE1 ---------
;(to trigger from RoboDK: use robot.RunCodeCustom("program id", INSTRUCTION_CALL_PROGRAM)
program_id = COM_VALUE1
SWITCH program_id
CASE 1
;-- run program 1 --
;钻()
;-------------------
CASE 2
;——2——运行程序
;Cut()
;-------------------
ENDSWITCH


Attached Files
.py KUKA_KRC2.py(Size: 29.94 KB / Downloads: 651)
#8
Hi Albert,
thanks again for the detailed explanation and advice. I can see how both options are working, the online programming does not even look as bad as I expected it.
Nevertheless I would prefer the offline programming version and I would kindly ask you to comment on my troubles of transferring and starting the program.
Is it possible to transfer the program to the robot and execute it immediately using the API?

As I wrote above, my guess would be:
Code:
run_mode = RUNMODE_MAKE_ROBOTPROG_AND_START # run_mode = 5
program.MakeProgram(path_folder, run_mode)
If you could have a look at that part again and tell me if/how this is possible, that would be great.
Automation is crucial to my project, that is why I am so eager to solve this.
谢谢!
#9
Quote: Albert
2- For online programming:
However, there is a workaround for this and you can call numbered programs. To do so, you have to trigger a program a program call with a number. Using the GUI or the API. An example using the API would be:
机器人。RunCodeCustom(“职业gram 5", INSTRUCTION_CALL_PROGRAM)

Besides my previous question, there is another thing I would like to know concerning the behaviour ofRunCodeCustom(orRunInstruction). IsRunInstructiona blocking call to python?
Let's say my code looks like this:


Code:
机器人。RunInstruction(program01, INSTRUCTION_CALL_PROGRAM)

机器人。RunInstruction(program02, INSTRUCTION_CALL_PROGRAM)


program01 and program02 are defined in the customised section of RoboDKsync.src.
RunInstructionis supposed to return 0 if the call was successful. Does this mean that it waits untilprogram01is finished or does it return 0 ifprogram01is existing?
Or in other words, if program01 contains WAIT = 5s, does it wait 5 sec before program02 is called?
Yes, the call to RunInstruction will block (wait) until the program you want to execute completes. Make sure to add a space between the ID of the program and the name. For example:
机器人。RunInstruction("Program 2", INSTRUCTION_CALL_PROGRAM)

I'm sorry I missed your question regarding the startup of the program on the robot from the API. This is possible. By default, this option only works with Universal Robots (given they are collaborative, it is possible to easily start a program remotely).

You can customize this implementation in the ProgSendRobot call of your post processor. Let us know if you need help to implement this behavior with a KUKA robot.

Code:
def ProgSendRobot(self, robot_ip, remote_path, ftp_user, ftp_pass):
"""Send a program to the robot using the robot IP provided.
This method is executed right after ProgSave if we select
the option "Send Program to Robot".
The connection parameters (IP and port) can be provided
in the robot connection menu of RoboDK or hard coded here"""

UploadFTP(self.PROG_FILES, robot_ip, remote_path, ftp_user, ftp_pass)




Users browsing this thread:
1客人(年代)