iiwa user keys

  • Hello fellas :hi-bye:,


    I am having trouble with defining user keys.
    I created own function for keys


    now here is the cache,
    If i put this function in background service, and call it from "runCyclic", I can lode code to controller. Background service start automatically (green light) but also stops automatically after approx 1s. It's obvious that service is terminated.
    but if I copy this same code to application and call this function and run it, it somehow WORKS ??? ???
    I'm using workstation 11


    any suggestion what could couse the issue ?

  • Cyclic means that the task is started periodically. If the previous task was not finished it will be terminated. This means an endless loop should be run in a normal background task not in a cyclic one.


  • Cyclic means that the task is started periodically. If the previous task was not finished it will be terminated. This means an endless loop should be run in a normal background task not in a cyclic one.


    Thanks for explanation :yesyesyes:. It makes sense. But it's interesting, that the sample in workstation .pdf doesn't show that....KUKA :stupid:...

  • Can someone please look at what i did here and let me know what i did wrong, somehow i can't get the user defined keys to be published!
    so i added the definition to a function and i'm trying to run it from the background application to make sure it runs all the time and i can access it at any time?



    public class LiveByteBackgroundTask extends RoboticsAPICyclicBackgroundTask
    {
    @Inject
    Controller kUKA_Sunrise_Cabinet_1;


    @Override
    public void initialize()
    {
    // initialize your task here
    initializeCyclic(5000, 50, TimeUnit.MILLISECONDS, CycleBehavior.BestEffort);
    }


    protected EolIOGroup ioPLC;
    protected AppControlIOGroup ioAppControl;
    protected ObjectFrame BaseFrame;
    protected ObjectFrame ToolFingerTCP;
    protected boolean initialized;
    String lastException = "";
    boolean x = true;


    @Override
    public void runCyclic()
    {


    try
    {
    if (AppSingleton.getInstance().initialized)
    {
    ioPLC = AppSingleton.getInstance().ioPLC;
    ioAppControl = AppSingleton.getInstance().ioAppControl;
    BaseFrame = AppSingleton.getInstance().BaseFrame;
    ToolFingerTCP = AppSingleton.getInstance().ToolFingerTCP;


    ioAppControl.setOut_LiveByte(ioAppControl.getIn_LiveByte());


    ioPLC.setOut_AtsPositionX((int) Math.round(BaseFrame.transformationTo(ToolFingerTCP).getX()));
    ioPLC.setOut_AtsPositionY((int) Math.round(BaseFrame.transformationTo(ToolFingerTCP).getY()));
    ioPLC.setOut_AtsPositionZ((int) Math.round(BaseFrame.transformationTo(ToolFingerTCP).getZ()));
    }
    }
    catch (Exception ex)
    {
    if (!lastException.equals(ex.getClass().toString()))
    {
    StringWriter errors = new StringWriter();


    ex.printStackTrace(new PrintWriter(errors));
    getLogger().error(errors.toString());
    }
    lastException = ex.getClass().toString();
    }
    while (true)
    {
    userkeyss();
    }

    }
    private void userkeyss()
    {
    IUserKeyBar functionbar = getApplicationUI().createUserKeyBar("funcbuttons");


    IUserKeyListener clickfuncbuttonslistener = new IUserKeyListener()
    {
    @Override
    public void onKeyEvent(IUserKey key, UserKeyEvent event)
    {
    // TODO Auto-generated method stub
    //key.setLED(UserKeyAlignment.BottomMiddle, UserKeyLED.Green, UserKeyLEDSize.Small);
    if (event == UserKeyEvent.KeyDown)
    {
    key.setText(UserKeyAlignment.TopMiddle, "Test");
    }
    }
    };


    IUserKey key = functionbar.addUserKey(0, clickfuncbuttonslistener, true);
    key.setLED(UserKeyAlignment.BottomMiddle, UserKeyLED.Green, UserKeyLEDSize.Small);
    functionbar.publish();
    }


    }

Advertising from our partners