Home Programming

Discussion

Left ArrowBack to discussions page
RoboBarRoboBar Posts: 6 Apprentice
Does anyone know what the max amount of conditional statements the UR5 can handle in a single parent program? I've tried over 100 conditionals in a single parent program and cannot get out of an infinite loop, but it will work with roughly 64 conditionals.If i add one more conditional i get an infinite loop error. Anyone have any ideas that could help me out ?

Comments

  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    @RoboBar I do not know how many conditionals you can have, I've never needed more than about 20 but what you are running into is an issue where the if statement is taking longer than 8ms to process and that is why you are getting an infinite loop. I'd recommend breaking your parent into two parent if statements with a sync() between the two parent if's. this will allow the process to get back in sync with the system and will eliminate that infinite loop. I've run into similar issues when using lots of sub programs and either select statements or if statements controlling the sequencing of the sub programs. 
  • RoboBarRoboBar Posts: 6 Apprentice
    How do I use a sync command to link the two parent programs I've broken the conditionals into ? 
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    Something like this

    Main Program
      if .....
      else if  #1....
      ...
      else if  #50.....
      sync()
      if .....just continue with your conditionals
      else if #1....
      ....
      else if #50....
      sync()
    
    subProgram #1
    subProgram #2
    ...
    subProgram #100
    
    
    

  • RoboBarRoboBar Posts: 6 Apprentice
    I've tried entering script code sync() where the last conditional is before the infinite loop begins and it is still giving me the same infinite loop error 
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    Post up your code or you can email it and I'll take a look. 
  • RoboBarRoboBar Posts: 6 Apprentice
    I sent the program file in a message to you, did you not receive it? 
  • DMO_UniversalDMO_Universal Posts: 4 Apprentice
    For extremely large if/elif chains you're going to create a lot of lag.  This lag was why the Switch Structure was added to the Polyscope interface.

    Are you able to switch to using a Switch?  It would allow you to fit scores of cases into a single Structural element, with no lag!
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    @DMO_Universal the only caveat is that switch only works with a single integer value, can't use for string values or choosing different inputs for different parts of the conditional. At least that is my understanding of how it works, if there's a way to use it differently I'd love to see it

    One workaround for using inputs or outputs is to create a variable which is the byte value of the inputs that way it becomes a single integer that you can switch on. 
Sign In or Register to comment.
Left ArrowBack to discussions page