Application lifecycle

  • Hi,
    I am a novice at LBR programming and I have a question about the application lifecycle, especially in T1 mode.

    My run() function consists of an endless loop handling events and driving the robot to various positions.

    Unfortunately I cannot find in the manual any condition to check to decide to abort the loop terminate the run() method - every solution I found is somewhat unsatisfactory.

    At the moment I tried this:

      • Running the loop in a thread and stop the run function from terminating with a modal dialog. Right after the dialog is closed, i interrupt the thread. Drawback - I have an annoying dialog on top of the output window

      • Using an user key to set a flag that gets checked at every cycle. Drawback: it is cumbersome, as there seems to be no way to automatically activate a specific set of userkeys (not that i found at least)

    Not tried - the user button on the flange. Drawback - it can be in a position uncomfortable to reach.

    What I would really like to know is how to handle the red square stop button on the smartpad - is it possible to programmatically detect it has been pressed? Is it setting something detectable by code?

    Any help would be really appreciated!


  • AD
  • Without any examples as to when, or why you want to end your run() method, it's difficult to determine exactly what functionality you want.

    When running in T1 mode, the application (okay actually only the movements, any logic code will carry on) will stop whenever you take your finger off the play button. The stop button will do as you require and stop the application running when in Auto. It is not accessible to the programmer by any means I know of, with the exception of the .net services which can be used to make plugins (I haven't used these on sunrise but expect they look to be similar to what is on a KRC4).

    A simple


    would end your loop and method. If you want to stop the program mid movement by some logic you would need to use conditions via the .breakWhen(ICondition condition) method of a motion object. The manual makes these quite clear.

    You're correct in that there is currently no way to automatically display a user key bar.

  • Sorry - I should have been more clear.

    What I am trying to find is a way to manually terminate an application by using an external button, ideally the square red button on the smartpad. While it easy to pause motions, the application is still running (I see the output in the pad "console")

    With 'terminate' I more specifically mean indicate to the application the user want to terminate the application so I can perform a "clean" shutdown (closing sockets, interrupting threads etc). I can't find any way to do this except using the user buttons (really inconvenient) or with a modal dialog (which covers the output).


  • Hi,
    thank you very much, as I stated on my original post, I already tried that ("Using an user key to set a flag...") but it is very clunky to use (" there seems to be no way to automatically activate a specific set of userkeys").

  • Try to end it with a UserKey.

    private IApplicationControl ac;

    I hope that this will halt you application, too.
    If you use:


    This will just stop motion but nothing else until the application finds a reason to pause completely (wait(), a new motion(sync)).

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now