Currently I have a subprogram initializing after a count variable has been initialized for inspection. How do I restart the program after that subprogram has run.
I have it bagging until the 10th part where it lays a part to the side. After it lays a part to the side I want it to restart. Right now it is trying to still bag a part that it doesnt have.
You’ll probably have to post some snippets of your code. You probably need to structure your main program to consist of one over-arching Switch/Case statement. I find that to be a very efficient way to handle branching program execution.
Something like this should be fine:
Oh and you should do another Assignment at the end of Case 2 to reset counter back to 0. Almost forgot that.
Yep see my example shell above. You want to put things like “BagPart” as one of the Case statements. PLC step logic works really well for these types of applications as well. Ask yourself what your process is at the high level. Break this down into discrete steps and ask yourself what conditions must be met to enter a given state.
For example, if “Inspection” had been step 1, then as the final instruction after calling your subprogram, it can set the Switch variable “Robot_Step” back to 0. If “BagPart” had been in Case 2, it would be skipped because Robot_Step is not 2.
The robot program is essentially just constantly scanning the Switch statement, and decides which step to execute based on the value of the variable Robot_Step. This can be set via sensors or inputs, or just sequentially by your other steps.
I kind of replicated my inspection counter step calling subprogram and copied my bagging folder and made that a subprogram as well.
counter=counter + 1
if counter < or = to 2
counter> or = to 3 would call inspection sub and reset counter to 0
Thank you for your help on all my questions so far.
Nice. Yeah same principle. As your jobs become more complex with more branching paths, you may still find the Switch/Case structure useful. This is especially true if you had had a subprogram call inside BagPart, since Polyscope will not call a subprogram from inside another (you have to trick it with script to do that). The Switch/Case structure compartmentalizes the code, and can make debugging easier.