@AZalmanov There is not a built in script per se that will do this, however, it's not that hard. One way to do this is to place your sub-programs inside of a switch statement that uses an indexer to call each subsequent step in the process, then you can start your program from wherever you want. The biggest change that this creates is that your program goes from being very linear, do A, then do B, then do C and execute all in one loop to a looping program where each loop executes one step in your switch case. From a human's eye, you won't notice the change but you might have to make some minor modifications to make the code execute correctly without any invalid setpoint errors.
So here is basically how we program our robots so that the customer can resume operations from anywhere in the program
First we create an installation variable called currentStep and set it to 0, we will use this as our step function in the switch statement. In the before start section of the program we will ask the user where they want to start the program, which step basically. If they choose 0 then we know they want to start at the beginning and we will then proceed to reset the cell and start from the beginning. If not, we have a homing routine to get the robot from its current location to the starting point for that section of code. That way we can automatically recover from a crash and resume operation where we were. Here's what the code in the body of the program looks like
switch currentStep:
case 0:
subprogram0
case 1:
subprogram1
case 2:
subprogram2
if (needToRedo1):
currentStep=currentStep-2
else if (needToRedo2):
currentStep=currentStep-1
end
end
currentStep = currentStep +1
if currentStep > 2:
currentStep = 0
end
So lets say I am in step 2, I decide that for whatever reason I need to reperform step 1, I will simply deduct from currentStep 2 indexes so that instead of becoming zero at the end of the loop currentStep becomes 1, since I have now reset it to 0 and then added 1 at the end of the loop. I could also jump forward from 0 to 2 by simply adding an index at the end of the subprogram0 before it returned to the main program. What we have found using systems like this is that we can have very complex programs that are making a lot of decisions on how to run on the fly but write simpler code. We simply include logic that allows us to set where the program is going next rather easily.
Hopefully this makes sense, if not let me know and I will try to explain better
I have several sub programs that each do a small process (I.e. picking up a spring, orienting, inserting in machine) . I have them each in an if statement so that if no part is detected the robot does not continue to do the remainder of the steps and moves back . That is fine but I also need to add a case within the subprogram that can discard the spring if it cant be aligned. So in this case I would need to jump back to the subprogram where I initially gripped the spring. I can make the first and last waypoint of all of the programs the same to remove the complication of finding a safe route to the previous program.