While Loop in URCap Stops Program

Our URCap we wrote controls a motor from the UR. We are adding a feature to wait for the motor to finish making its move before proceeding onto the next program node.
We have stripped down the bug into the most basic code in order to show the problem.

Versions

We tried

  • SDK 1.4.4 and also SDK 1.9.0
  • Polyscope versions 5.3, 5.4, 5.5, 5.6, 5.7, 5.8

Impact

UR program does not play all the way through

Issue details

We are getting a really weird “bug” that we have been attempting to fix for several weeks now. The issue arises whenever we put a While Loop into our URCap ProgramNodeContribution generatescript. The UR program will play our URCap node and then the program will stop after the execution of our URCap node (when program should not stop). This only occurs:
1.) If there is a While Loop function in our URCap generatescript function
2.) When the program is first loaded (either by opening the program or if program is auto-loaded on boot-up), we initialize the robot and press play without pressing any other buttons.

Use Case and Setup

While loop in a URCap ProgramNodeContribution generatescript

Steps to Reproduce

Place this code in your ProgramNodeContribution generateScript function.
This can be the only script generated in the URCap.

writer.assign(“ioVal”, “False”);
writer.whileCondition(“ioVal==False”);
writer.assign(“ioVal”, “get_standard_digital_in(0)”);
writer.sync();
writer.end();

Create a UR program, insert URCap node and a Wait into program. Save program. Open any other program or power off the robot. Load the program with URCap node (either by opening the program or if program is auto-loaded on boot-up), initialize the robot and press play without pressing any other buttons.

Expected Behavior

We would expect the program to play all the way through all the program nodes after the digital input goes high.

Actual Behavior

The actual behavior is that the UR program stops shortly after executing our URCap node

Workaround Suggestion

1.) Remove While Loop. If we removed the while loop in our URCap, program would also run flawlessly
2.) Load the program and then click any node in the program tree (any other node except the URCap node).

  • For example, we had a “Movej” node and a “Wait” node in the program. If we clicked on one of those nodes, and press play, program would run flawlessly. If we loaded the program and did nothing else but hit play, program would execute up to our URCap node and then the UR program would stop (no errors in the log file).

Hello @jordan,

Thanks for the detailed report, I have forwarded this along to our dev team to investigate.

Hi @jordan, can you share the files tried/tested with me? support@universal-robots.com
Thank you.
att.
Tomás

We somewhat figured out the issue. If the UR program is played upon first loading the program (either by opening the program or on auto-load on power-up) without clicking any of the program nodes, the UR program will execute the program node and also trigger the openView() function of each program node. If the operator clicks any of the program nodes in the program tree, the UR program will obviously still execute all of the program nodes, but it WILL NOT execute the openView() of each of the program nodes.

We were calling the InstallationNodeContribution openView() function inside of the ProgramNodeContribution openView() function to update the installation variables. For some reason, if we inserted a while loop in our ProgramNodeContribution generateScript, the call to the InstallationNodeContribution openView() function would stop the program. We modified our program to not call the InstallationNodeContribution openView() and this fixed the issue.

Still not answered:

  • Why is ProgramNodeContribution openView() of all of the program nodes triggered only when the UR program is first loaded (without clicking any program nodes).
  • Why does a call to the InstallationNodeContribution() openView() inside of the ProgramNodeContribution openView() crash the program ONLY if a while loop is present in the ProgramNodeContribution generateScript()?

@jordan

Any changes to the DataModel of either a program- or installation node while a program is running, will terminate the running program. This is similar to if you modify any program node while the program runs.
Thus, if your openView()-method alters the DataModel, this will halt the program execution.

Typically when the program is running in the “Program”-tab, PolyScope will focus on and open the node that is being executed. Hence, it will iteratively call openView() for all nodes in the program. If you had selected a particular node, PolyScope will stay on this node, and thus not call openView() for the nodes in the program (and then not triggering the DataModel change).