I have a question. In the automation project, it is often necessary to count the movement beats of robots. In the figure below, multiple subroutines are created. Is there a way to count the beats of a single subroutine (that is, the robot’s movement time), or multiple subroutine beats at the same time?
Hi i think you can create a new variable for every subroutine to count how many times it ran. And simply you can increase it by 1 every time routine is called. In routine you can use your first command for assign Counter = Counter + 1.
Oh no, I want to calculate the motion time of the robot subroutine, not how many times it runs.
I would recommend you use the Post Processor add-on found on the forum along with a virtual controller for calculating the cycle times, e.g. Kuka OfficeLite. For example, use the add-on to export the robot program to a testable format, and then use a controller to measure cycle times.
If you cannot do that… you can use API to try and calculate the motion time.
The Robot Executor behavior of the robot should have a StatementHandler property, which you can use to the control the execution of statements. A StatementHandler is a Python Process Handler behavior. It has a script, which would allow you to calculate the time it takes to complete the routine.
The Robot Executor in Python is vcExecutor, and it has a method for calling a routine in the robot program. So a simple test of comparing the simulation times before and after the call and completion of the routine could give you an idea.
The Robot Controller in Python is vcRobotController, and it has a method for creating a motion interpolator and others for testing motion targets, but this is something you probably should not do in this case.
A curve ball. I don’t remember, but I think the Print statement in a robot program does print the simulation time in the Output panel. Therefore, you could try to do option 2 via the GUI/Program Editor panel.
Notes about Options 1-4
It might not be accurate, but can serve as a rough idea/estimate. Be aware that you would have to implement a way to monitor motion statements and not other types in the routine. But if the goal is just to record the duration of a routine, you could create a script and run the routine several times to get a sample size and average time.
Thank you very much, but I think it will be a good feature to apply this function to a future version, which is combined with the request of my previous automation project, thank you again!
I’d do it with a simple Python script as an application script, command or embedded to a component e.g. the robot.
My recipe would be as follows:
- In vcExecutor register to OnCurrentStatementChanged event
- In the event handler
- capture SimTime
- get the CurrentStatement property (of VcExecutor)
- act based on the ParentRoutine property of that vcStamement (if it's different than in previous event start a new timer etc.)
- Store/output the times as needed