How to jump to a certain line in the program via Script or Assignment

Hello, all

Is there anyway to have a program jump to a certain line in the program tree using Script or Assignment commands? Picture attached below:


I would like if “Restart=True”, to then jump to line 76 in the program tree (start back over at MoveL, T2Approach.

Bonus question: if there is also anyway I can add to the “count” in the palletization program, both when the condition is and isn’t met.

Thank you all again in advance for your help. I wasn’t able to find anything in the PolyScope Script manual.

There is not an explicit jump command, no. You can, however, put everything from line 76 on in a loop, and loop while restart == True instead. Then any code after this loop would only execute when restart == False. This should accomplish what you’re looking for.

As for adding to the count, if I’m understanding you right, all you have to do is just use an Assignment node and say var = var + 1. Logically, it sounds like you’re asking if(True OR False) which is ALWAYS true. Therefore you don’t need to make it a conditional at all, just increment the variable on its own line all the time.

3 Likes

what about jump_to_label function from urscript

1 Like

That command doesn’t exist. At least not in the URScript manual for Polyscope 5.19. Can you show the documentation for this command?

No document. But i found it in the script send from 30001 port if you set a breakpoint in the program tree

4 Likes

Wow. Had no idea this was a thing. Crazy good find. Can’t believe that isn’t documented in the Script manual

1 Like

Wait. Is this a viable script command usable within a program? Or just as a command that can be sent to the interface?

Straight up undocumented script command.


If you press play here, the first thing that shows up is “test2”

3 Likes

What. Why is that not documented anywhere … Many years of UR programming where that command would’ve been so useful so many times.

I guess it’s only really usable in PolyScope 5 with line numbering, but still. :slight_smile:

Well. I guess it’s also a bit unpractical given that it looks at line numbers and not actual labels. So if a new node is inserted in the beginning of a program, you’d have to shift all your labels.

Woah, I’ve been looking into how to achieve something similar to a Jump to label on the UR. Can you share some more on this. what does the actual script look like to achieve this?

I mean you’re looking at it. That’s the whole script. It just jumps you to that line number. As efn points out, it’s not super great, since anything that changes your line numbering will in turn change where the jump instruction goes to. I spent a little time a while ago trying to guess my way into a hidden “label” instruction but didn’t find one.

Otherwise you can check this link: Jump Flag Program Node - #4 by eric.feldmann

Maybe that’s something you can use.

Awesome, thanks for the information! That gives me a few options to try out. Still mind-blowing how UR is the only Robot Manufacturer I’ve dealt with without a jump/label command. I get why to some degree for simple applications, but for more complicated applications where you need to add in a check/retry/additional process based off certain conditions (especially after a deployment) it can become frustrating having to restructure the entire program to make it functional. It is what it is. Thanks Again!

Hey all, sorry to resurrect an old thread again, but it just occurred to me to try this and I’m super excited to see how this might screw me over later, but you can 100% use this jump_to_label() effectively, you just have to pair it with a label definition

URScript designates a label with a $, number, text. So if you insert a script line that follows that pattern, you can define your own label and then jump to it. In my example here I went ahead and chose 90,001 figuring that a decent schema for custom label would be something starting in 90,000, since I hope to God I don’t ever have 90,000 lines in a real program. You would not want to use any number small enough that Polyscope would be automatically assigning that label as a line number, otherwise you’ll get a duplicate label error. The obvious benefit here is that the line number we are jumping to will NOT change based on where it’s at in the Polyscope program! I have only tested and proven that this WORKS, not that there are potential issues with it. Would love someone from UR to chime in on any dangers here, but otherwise this seems like a fantastic tool to add to the tool belt.

7 Likes

My God, what a great find.

Thank you for your sharing :grinning_face_with_smiling_eyes:

1 Like

That’s amazing. Thank you for sharing your find with us, Eric!

I really wonder why UR has not shared this function with the public … Maybe it’ll mess the execution up if you jump into a thread or subprogram directly, but I can’t see any other potential risks as long as you know what you’re doing.

1 Like

I’ve been using this functionality for several months now and it hasn’t caused me any issues (within a single main program).
There’s just one feature I’m missing, which is available directly in PolyScope - reading the current label so that the program can return to the instruction where execution was interrupted.

I managed to work around this by reading the currently executed script line and matching it with the label assigned to that line, but maybe someone has found a variable or a get-function that allows reading the current label directly?

1 Like

What method are you using to read the currently executing script line?

var = get_rtde_value(“script_control_line“)

1 Like