Home Programming

Discussion

Left ArrowBack to discussions page
TVRUTVRU Posts: 7 Apprentice
We're integrating a UR in combination with a signal light. The signal light represents any required action:
  • Green: robot running without issues
  • Yellow: operator input required (e.g. blocking pop-up active)
  • Red: robot stopped, or error active
Green and red don't pose any problems, after attaching a couple of relays and configuring outputs, but an easy solution to turn on the yellow light when operator input is required turns out to be harder than we thought.

Now (as a short-term solution) we're manually building code around every pop-up, or scripting it, so the yellow signal light is on as long as the pop-up is active. This however seems a bit unwieldy, since:
  • .. there is an option in scripting to set 'blocking' to true or false, which suggests it's a variable that can also be requested if necessary. We didn't find a way however to read this variable in a separate thread.
  • .. the run-mode of a thread is changed from running to paused. We didn't find a solution to check the run-mode in a separate thread, to set the signal lights accordingly.
Did we just miss an option in scripting, didn't we look in the right solution space, or is the unwieldy way the only way?

Comments

  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,131 Handy
    edited January 8
    No, you didn't miss anything.  Basically the easiest way to do this is to write your own function that does exactly what you want it to do.  Something like this would work

    def customPopup(msg, blocking = True): #Would give you the ability to use this in a non-blocking fashion and should not flash the yellow light since the thread would be killed as soon as it was started
      local threadID = run flashYellowThrd()
      popup(msg, title = "Our Popup", warning = False, error = False, blocking = blocking)
      kill threadID
      set Yellow Low
    end

    thread flashYellowThrd():
      while (True):
        set Yellow High
        wait 0.5 
        set Yellow Low
        wait 0.5
      end
    end
    Then in your code when you want to call the custom popup just use a single script line

    customPopup("Some message that requires an operator to be notified that its on the screen so flash the yellow light")

  • TVRUTVRU Posts: 7 Apprentice
    Thanks for the answer! I'll try it in an hour, and hope to come back to you asap.
  • TVRUTVRU Posts: 7 Apprentice
    It took some time, but I got it up and running. I had some trouble with the syntax, which is understandable if you copy the script above without checking it '^^

    Thanks a bunch!
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,131 Handy
    You're welcome, glad that it worked for you.
  • TVRUTVRU Posts: 7 Apprentice
    I run into problems when trying to import the scripts.

    In order I did:
    1. Create two separate script files: CustomPopup.script and ThreadBlinkYellow.script
    2. Import them in BeforeStart - this resulted in a syntax error, so I deleted it again.
    3. Created a separate thread in which the ThreadBlinkYellow.script is ran - this also resulted in a syntax error, so I deleted it again
    4. Cut the thread call and kill from the CustomPopup.script and ran it in BeforeStart - this also resulted in a syntax error, so I deleted it again. It seems it doesn't like to be initiated without having a value for 'msg'
    5. Not literally import the scripts in the program, just try to run the single-line command 'customPopup("test") - this resulted in an error, as I expected, but it was worth trying.
    When I search the forum I come over this page: https://www.zacobria.com/universal-robots-zacobria-forum-hints-tips-how-to/thread-in-script-file-example/. This didn't help me any further either.

    So, as a follow up question: where should I import the scripts, to be able to run it later-on?

    Thanks beforehand!
  • TVRUTVRU Posts: 7 Apprentice
    I run into problems when trying to import the scripts.

    In order I did:
    1. Create two separate script files: CustomPopup.script and ThreadBlinkYellow.script
    2. Import them in BeforeStart - this resulted in a syntax error, so I deleted it again.
    3. Created a separate thread in which the ThreadBlinkYellow.script is ran - this also resulted in a syntax error, so I deleted it again
    4. Cut the thread call and kill from the CustomPopup.script and ran it in BeforeStart - this also resulted in a syntax error, so I deleted it again. It seems it doesn't like to be initiated without having a value for 'msg'
    5. Not literally import the scripts in the program, just try to run the single-line command 'customPopup("test") - this resulted in an error, as I expected, but it was worth trying.
    When I search the forum I come over this page: https://www.zacobria.com/universal-robots-zacobria-forum-hints-tips-how-to/thread-in-script-file-example/. This didn't help me any further either.

    So, as a follow up question: where should I import the scripts, to be able to run it later-on?

    Thanks beforehand!
Sign In or Register to comment.
Left ArrowBack to discussions page