Universal Robots Forum

Halt program execution at start

Hello, I’m currently developing a swing URCap that moves an axis. Currently we are able to move the axis from installation and program nodes. We do this communicating via RTDE with a thread that is in charge of the communications with the axis, so far so good.

I wanted to implement a feature similar to the robot automove in such a way that if the user starts the program but the axis is not in position of the first movement command, the program halts and the user has the option move the axis manually or automatically. I’ve managed to get the logic that detects if a certain contribution is the first one to be called, however I’m unable to make the desired behavior works correctly. So far, I’ve tried the following approaches unsuccessfully:

V0.1 – Custom Implementation of the robot movements and robot callbacks methods (com.ur.urcap.api.domain.userinteraction.robot.movement)

Implementation - The popup ends up being a JPanel that it’s called during the execution of the generateScript method. I have to put a loop so the generateScript freezes while the user is interacting with the screen.

Problem – this method does not truly halt the execution of the robot program itself and during my tests it showed inconsistency and the messageBox of starting program appears in front of my custom UI.

V0.2 – Generating popup command in the script

Implementation - I register a variable during the execution of the generateScript method using SwingUtilities.invokeAndWait (as far as I’m concerned, the model.set needs to be done in the UI thread). This is done in order to establish a flag that the script can recognized and execute the popup instruction only the first time.

Problem – The popup appears on the first instruction of the axisMovement command which is not desired. If there is any other instruction before that, the popup won’t show until the axis instruction

V0.3 – Communicator and sendScriptWithButton examples

Implementation – I send the popup command to the secondary client during the generateScript method

Problem – According to the forum, the secondary client seems to be in another context of execution. So, I can neither halt execution of the main program nor set a flag system between the secondary client and the main program. (I’ve tried this with the ports 30001 and 30002).

Any of these tests could be very well failing because of my particular implementation but it seems that I cannot make it work regardless. Any suggestion on how to deal with such a feature? Are there any more approaches that I could test? I guess that if the event of the play button was available i could stop execution there before calling the generateScript method, but seems to me that it’s not the case.

P.D. Sorry for any biggies regarding grammar, English is not my first language.

1 Like

After some tests i have realized that the commands sended through the secondary client can’t take physical time (that seems to include freezing the program) so this approach is not valid