Home Programming

Discussion

Left ArrowBack to discussions page
LavertueLavertue Wrist Camera URCap 1.3.0 Posts: 9 Apprentice
Hi,

I am aware that I can create a ''global'' variable by the creating an installation variable, but it seems that I can only create an integers variable. Is there a way to create a boolean  global variable (or string for that matter)? My problem is that I use boolean variables  defined in the main program in the subprograms and at the start I always get an error message telling me: variables XXX is already created, do you want to automatically rename it? 

thanks

Best Answers

Comments

  • LavertueLavertue Wrist Camera URCap 1.3.0 Posts: 9 Apprentice
    Thanks Matthew,

    that is what I understood at first, thank you for confirming. I'll make sure to use integers next time I have to use variables in multiple sub programs!
  • LavertueLavertue Wrist Camera URCap 1.3.0 Posts: 9 Apprentice
    Thank you Louis, very helpful.
  • louis_bergeronlouis_bergeron Posts: 94 Handy
    You can also create installation variable and give a value to "True" at the creation.  This variable will then be available for all program.


    Louis Bergeron
    Integration Coach
    robotiq.com
    [email protected]
  • LavertueLavertue Wrist Camera URCap 1.3.0 Posts: 9 Apprentice
    Do you mean creating (in the "before start")  assignements doing:
     
    TRUE:=1
    FALSE:0

    then I have assignements doing:

    myvar:=TRUE
    myvar2:=FALSE


    This way I could use integers, but see a "boolean logic" in my programming? 
  • louis_bergeronlouis_bergeron Posts: 94 Handy
    @Lavertue

    Within the installation variables screen.  Take care of uppercase and lowercase when you type 'True'.








    Louis Bergeron
    Integration Coach
    robotiq.com
    [email protected]
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    @louis_bergeron do you know if that is new with the later releases, I don't recall being able to do that with the older versions of the software.  I learned something new today, thanks!
  • louis_bergeronlouis_bergeron Posts: 94 Handy
    @matthewd92
    I don't know since when it's available.  I just tried it on one robot and it works.  I was also surprised.
    Louis Bergeron
    Integration Coach
    robotiq.com
    [email protected]
  • LavertueLavertue Wrist Camera URCap 1.3.0 Posts: 9 Apprentice
    Hey everyone thanks for the help, 
    I have tried this method and I get good results when I am creating a new program or when using the UR simulator, but when I try to add it to an existing program I still get the same mistake (see picture below). This happen when I load the program, it does not stop it from working, but I have to hit cancel about 20 times in this particular program. On the end-user side it is not the most optimal thing. 

    My understanding of the UR was that it writes its variables when he sees them, so a script defining global variables should not cause ths error... Any idea what could cause this?
    Note: the UR simulator on my computer never produce this message.
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    UR compiles and writes a script file when you press play. If the variable is declared more than once it needs to know if it should treat as the same variable or a different variable. What version of polyscope are you running in the robot? 
  • T800_412T800_412 Posts: 51 Apprentice
    All, this is good information, and I have a question about renaming. What happens to program execution if I select "automatically rename" when these popups are happening?

    My original expectation for using the same name in the sub-program is so the value for the variable in the main program and sub-program is passed back and forth. So, for example, the main program has a variable "gadget_detected" that is solved for in one of eight sub-programs that run based on which gadget type is selected. (The sub-programs have the Camera Locate nodes in them which have to be different for each gadget type)
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    If you choose rename then they will no longer be the same variable. You could also use installation variables then you don’t have that issue. If you close the program, create the installation variable with the same name then when you reopen you’ll have the option to use the installation variable and once you select that and save it won’t ask again
  • T800_412T800_412 Posts: 51 Apprentice
    Here's a frustrating discovery. If you allow PolyScope to use installation variables to replace the original variables in your program, all those variables become unusable throughout the program, if you then remove the installation variable.

    For example, I had "var_1" used throughout the program and sub-program, so I made and installation variable "var_1". I allowed PolyScope to convert the program variable to an installation variable. I then decided to get rid of some of the programming from a sub-program and merged it into the main program in a folder to keep it organized. When trying to run the program the incomplete message popped up. All of the parts of the program that referenced "var_1" had yellow nodes, even though Polyscope showed "var_1", appearing to be normal. To fix it, I had to delete, then re-enter "var_1" in all those places.
  • matthewd92matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
    You just need to type into the installation variable True or False initially. I can’t remember when they started supporting non-integer types but in 3.4 and 3.5 it’s supported. 

    You would need to close the program program before deleting it then it should work when you open the program back up. You removed the instantiation of the variable from the program when you deleted the installation variable. 
Sign In or Register to comment.
Left ArrowBack to discussions page