Discussion

Left ArrowBack to discussions page
StoopidEngineerStoopidEngineer Posts: 15 Apprentice
Hey All - I'm trying to do some very, very basic gripper control using the built-in digital I/O and am having all sorts of seemingly stupid problems. 

To distill the problem as much as possible, I wrote a simple sub-program to open a gripper (set 'close' bit to low, wait, set 'open' bit to high, wait, assign a variable) in the UR GUI which works fine as part of a larger program.

I take the script file of the entire program, steal the sub-program out of it and paste it into a blank script file to create a script that is intended to do what the sub-program did. Because this is the only way I'm aware of to circumvent the inconceivable inability of UR robots to have sub-programs call other sub-programs (and I asked UR about it several times.)

I then turn around and load the script file into the existing program in the GUI to wind up with a script file I should be able to call anywhere I want to execute the previously made sub-program. 

The problem that I'm having is that the script seemingly has no impact on the program - as far as I can tell, the controller runs through the script, and it just has no effect on anything. Do I need to redefine variables or input ranges within the script, even though they are unchanged from the main program? 

I assume there has to be something really basic and obvious that I'm missing, but I can't seem to figure it out. I appreciate any advice you can offer. 

Thanks!

Best Answer

Comments

  • StoopidEngineerStoopidEngineer Posts: 15 Apprentice
    In this screenshot, the 4 sub-programs run fine and work as intended, the 4 scripts following them are the copy and pastes from the main script file, and seemingly do nothing. 
  • Nicholas_FrancoeurNicholas_Francoeur Posts: 93 Handy
    @StoopidEngineer, seems like you simply need to call your CLOSE_GRP_01() function inside you program.

    All your functions can be defined once in the before start sequence and then use the functions as many times as you wish by calling them.
    Nicholas Francoeur
    Co-Founder | Vanguard Robotics
    e:   [email protected]
    w:  vanguard-robotics.com
  • StoopidEngineerStoopidEngineer Posts: 15 Apprentice
    @Nicholas_Francoeur I understand that part, only because they were previously giving me definition errors when I kept accidentally redefining them, instead of just calling them. I just happen to call define them all at the top because some are only used in certain 'if' statements, meaning I can get to the bottom of the program without having run the condition the script was defined in, resulting in an undefined error. So I define them all at the top and call them throughout the program. 

    That said, they do not seem to have impact on the program here where they are defined, or in any of the places where they are called for use. 
  • Nicholas_FrancoeurNicholas_Francoeur Posts: 93 Handy
    edited April 10
    Can you share your program?
    Nicholas Francoeur
    Co-Founder | Vanguard Robotics
    e:   [email protected]
    w:  vanguard-robotics.com
  • matthewd92matthewd92 Posts: 967Founding Pro, Tactile Sensor Beta Testers Handy
    Sharing your code would be very handy. We use functions extensively and haven’t seen that issue so should be something simple to help you with. 
  • StoopidEngineerStoopidEngineer Posts: 15 Apprentice
    edited April 10
    @Nicholas_Francoeur  @matthewd92  I'm still trying to make mental sense of what the UR calls from outside the main program, and what is stored inside of it, and when external subprograms get updated/saved over. But I attached the .urp - I'm sure it's a simple, obvious thing that I'm getting wrong, but I can't seem to figure it out. Thanks
  • Nicholas_FrancoeurNicholas_Francoeur Posts: 93 Handy
    @StoopidEngineer, everything seems good. Make sure all conditions are met so that you know you are actually looping in where you're calling your functions. Try using the textmsg() function at a couple of places to know when you entered a statement or not. Or try a simple program where you open and close the gripper with those two functions.
    Nicholas Francoeur
    Co-Founder | Vanguard Robotics
    e:   [email protected]
    w:  vanguard-robotics.com
  • StoopidEngineerStoopidEngineer Posts: 15 Apprentice
    @Nicholas_Francoeur - That's the issue: I've made a simple program that has nothing but the sub-programs to open and close the grippers, and then the script files to open and close the grippers. The sub-programs work, the scripts don't, and I can't figure out why. 
  • Nicholas_FrancoeurNicholas_Francoeur Posts: 93 Handy
    Please send us this program so that I can test it over here.
    Nicholas Francoeur
    Co-Founder | Vanguard Robotics
    e:   [email protected]
    w:  vanguard-robotics.com
  • matthewd92matthewd92 Posts: 967Founding Pro, Tactile Sensor Beta Testers Handy
    I took two of your scripts and created a sample program and the scripts execute fine.  I then placed the scripts into subprograms and then executed it again and the scripts still run fine.  Here is the test program that I created, please try running it and see if the scripts are executing for you.
  • StoopidEngineerStoopidEngineer Posts: 15 Apprentice
    @matthewd92 We're behind a pretty tenacious firewall here, so I wasn't able to download your program, but I think I may have figured out what I wasn't understanding before based on your and Nicholas's comments. 

    From what I'm seeing, the scripts that contain the initial definition don't actually 'do' anything in the robot program? I made a program with the 4 sub-programs (open each gripper, close each gripper) followed by those programs in script form, with the script commands detailing out the 'program' and ran it - again, saw the UR GUI sub-programs execute and act as expected, but those were the only thing looping, so I put script commands in the UR GUI to do nothing but call the script files I had just defined, and then (finally) got the program to act the way I thought it should have. 

    So definitely a learning experience for me, and I can at least feel OK about getting the script files made correctly. I'm apparently just not sharp enough to know how to call them properly. 

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