Merging Multiple Programs in Polyscope

Hi all,

New to cobot world…

I have several existing working programs for a UL5e robot.

We are now wanting to create a master program so that each programs can be selected from a selector switch based on IF statement, i.e when input 1 selected, execute program 1, when input 2 selected, execute program 2.

I’ve tried adding each program in as subroutines based on IF statement but because there are subprograms already used within each program, Polyscope doesn’t like that.

Have also tried adding each program in as script code, but the programs don’t seem to get executed at all.

Is there a way to achieve this easily? Without having to re-write all the program in Polyscope?

Thanks a lot.

Yes, you just have to change how the subprograms get called. Instead of using the built-in subprogram call, insert a script node and title it the name of the subprogram with (). Then you can just type that name() and Polyscope will jump there. Doing this, you can have “subprograms” within subprograms. See this post for a quick example:

1 Like

Hi Eric,

Thank you very much for your reply!

Just to confirm that I understood the workaround correctly. So I’ll need to change the way how Program 1 calls for the sub programs in order to be able to call Program 1 as a subprogram in the Master program? Please see my very basic diagram below.

And using the example you had from the older post, all the code for subprogram ‘label1’ will be inside the blue box shown below? Does that mean ‘label1’ will no longer be a standalone .URP file but just a section of the code within the robot program??

image

Yep I think you understood it correctly. The best example I can give is if you’re using a gripper and a Switch/Case structure. For ever grip/release, you may have a few instructions. Such as Set an output, Wait a time, check a sensor, throw a popup if error. Pretty basic stuff, but stuff that needs to happen every single time you grip or release. This makes for an ideal subprogram, but then you run into the problem if you’re gripping/releasing as a call from the main Switch/Case as subprograms as well.

So instead of making the grip/release commands it’s own .URP and calling it via a subprogram, just do what you’re describing above and place any code you want to run multiple times from within a subprogram call, inside this sort of “empty” subprogram and call it with the script line.

1 Like