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

Merging the code of subprogram in the main program


I made point follow project for scanning tool. In the program events I am calling python program to get different orientations of the tool on each point.
On simulation everything runs fine. I have all the orientation and movements I need. The problem comes when generate the tp program. Instead of rough code I get "call srm1" (srm1 is the name of the python program). I don't need to call sub program. I need to output the real cntent of the srm1 in the main program.

21:J P[2] 20% CNT1  ;
  22:L P[3] 1000mm/sec CNT1  ;
  23:L P[4] 10mm/sec FINE  ;
  24:  CALL srm1 ; 
  25:L P[5] 10mm/sec CNT1  ;
  26:L P[6] 1000mm/sec CNT1  ;
  27:L P[7] 10mm/sec FINE  ;
  28:  CALL srm1 ;
  29:L P[8] 10mm/sec CNT1  ;
  30:L P[9] 1000mm/sec CNT1  ;
  31:L P[10] 10mm/sec FINE  ;
  32:  CALL srm1 ;

Is it possible to avoid the program call and merge the code of the srm1 to the main program code?

(Inline subprograms is checked)
Make sure to rename your subprogram to srm1. On the other hand, this feature does not work with Python subprograms.

If you want to embed a Python subprogram, a workaround could be to follow these steps:
  1. Use the Quine post processor and generate the Python program (srm1). This will output a Python program.
  2. Execute the Python program that was generated. This will create a new program in your RoboDK project.
  3. Generate the parent program once you have the srm1 program in your project.
If you can provide us with the RoboDK project we can help you better.
The program created with the Quine post is not working for me because it contains fixed positions. 

#MoveL Pose(222.853, 195.145, 199.228,  -11.892, -5.093, -135.023
    AutoTarget0 = RDK.AddTarget('AutoTarget 0',robotFrame,robot)
    AutoTarget0.setPose(Pose(222.853195.145199.228,  -11.892, -5.093, -135.023))
    #MoveL Pose(222.853, 195.145, 199.228,  5.204, 11.844, -136.048)
    AutoTarget1 = RDK.AddTarget('AutoTarget 1',robotFrame,robot)
    AutoTarget1.setPose(Pose(222.853195.145199.228,  5.20411.844, -136.048))

The idea is to make incremental movements according to every point of the point follow project.

Attached Files
.rdk   PS13srch_test_v3.rdk (Size: 7.18 MB / Downloads: 299)
There's a way to do this, but it will require a bit more Python coding.
You will need to create a Python program that modifies the content of the Point Follow Project program every time you reach your srm1 program call. In fact, you need to replace your srm1 with it's actual content (that could be done directly in the srm1 python script).
Here's a basic example of how you can modify instructions in a program using Python:

Take a look and let me know what you think.
I did not open your station. I'm just answering based on your explanation as I'm a bit in a rush.

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


Users browsing this thread:
1 Guest(s)