Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing postpocessors through a python API for varying robot programs
#1
Hi RoboDK team, 

I want to ouput multiple robot programs for a single robot movementes through a python API. 

For example, a particular block of robot movements should be exported through KR C4 whereas other block of robot movements should be exported to a Kuka.CNC program. 


to explain: 

// defined parameter: imports, robot, robot_base, path etc. 

RDK.setRunMode(3)
post_processor = "KUKA_KRC4"

robot.setParam("PostProcessor", post_processor)
RDK.ProgramStart('Prog1', path,  post_processor, robot)


...
// movements for Prog1 
...

RDK.Finish()   //finish the movements for Prog1 and export a KR C4 program 
RDK.setRunMode(3)
post_processor = "KUKA_CNC"
robot.setParam("PostProcessor", post_processor)
RDK.ProgramStart('Prog2', path,  post_processor, robot)

...
// movements for Prog2 
...

RDK.Finish()   //finish the movements for Prog1 and export a KUKA_CNC program 

...
// Further moves
...
#2
This should be possible. The sample code you shared looks like you are heading in the right direction.

What issues did you have?
#3
Hi Albert,

Thanks for the response. I tried a code similar to my sample code and realized, the program exports just the prog1 and neglects everything after the first RDK.Finish() command.

I mean, the movements of prog1 are only exported as the .src, I dont get Kuka_CNC.

I believe it should work if I create multiple functions that export particular robot program. Like Def prog1(movements_for_prog1) Def prog2(movements_for_prog1).

But I would like to have it similar to the one I described above.
#4
Can you share your script here with a demo station, this will help us help you.

Jeremy
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel


#5
Attached is a demo example. 

The station has a example program (python) that switches in between the postprocessors.

I have added some comments, the code throws a error when RDK.Finish() is called, if I comment the RDK.Finish() function in between the code the, simulation works smooth however the desired output i.e. 3 seperate robot programs are not produced instead a single robot program (KRL) is obtained. 

Please let me know! 

P.S. Please define a output path in the python program main

Best, 
Pradnil S Kamble


Attached Files
.rdk   Example.rdk (Size: 1.18 MB / Downloads: 33)
#6
You can fix the issues in your script by making these modifications:

  1. You should call RDK.Connect after RDK.Finish (workaround, for some reason the API is not recovering/reconnecting automatically)
  2. The path to the posts folder for Program start should be a valid path so you don't see a popup to save the program.
  3. The name of the post processor should exactly match the post processor file in the Posts folder, it is case sensitive.
I attached the modifications I did to your script to make it work.

Code:
    # Use the KUKA CNC post
   post_processor = "KUKA_CNC"
   robot.setParam("PostProcessor", post_processor)
   RDK.setRunMode(RUNMODE_MAKE_ROBOTPROG)
   RDK.ProgramStart('Hex', r"C:/Users/UserName/Downloads/", post_processor, robot)

   # new target on active base
   base_target = park = RDK.AddTarget("Base_target", base)
   base_target.setAsCartesianTarget()
   base_target.setVisible(False)
   xyzabc = [0, 0, 0, 0.0, 0.0, 0.0]
   base_target.setPose(KUKA_2_Pose(xyzabc))
   robot.MoveL(base_target)

   # make a hexagon there
   poseref = base_target.Pose()

   for i in range(7):
       ang = i*2*pi/6 #angle: 0, 60, 120, ...
       posei = poseref*rotz(ang)*transl(100,0,0)*rotz(-ang)
       robot.MoveL(posei)
   
   robot.MoveJ(base_target)


   #End KUKA CNC program
   RDK.Finish()


   RDK.Connect() # Important if you want to continue using the API


   # Go back home with  KRC 4
   post_processor = "KUKA_KRC4"
   robot.setParam("PostProcessor", post_processor)
   RDK.setRunMode(RUNMODE_MAKE_ROBOTPROG)
   RDK.ProgramStart('Home', r"C:/Users/UserName/Downloads/", post_processor, robot)

   robot.MoveJ(robot_base)
robot.MoveL(...)

   RDK.Finish()
  




Users browsing this thread:
1 Guest(s)