Save program as it appears in Polyscope

I would like to save the robot program as it appears in Polyscope to look at in Windows. It’s useful when debugging someone else’s program that’s hundreds of lines. The txt file has excess lines and the script file has excess such as URCap EOT stuff. It’s cleaner in VisualStudio but sometimes I want to print the code. I just want a file with the same Polyscope program seen on the robot. Is it possible?

There’s an offline simulator available on UR’s website, which gives you the PolyScope interface in a Linux distribution. :slight_smile:

It’ll require VMWare og VirtualBox to run, but you can read more here:
https://www.universal-robots.com/download/software-e-series/simulator-non-linux/offline-simulator-e-seriesur20-ur-sim-for-non-linux-5145/

This allows you to open .urp files on your PC. You can save programs directly onto a USB on the physical robot.

1 Like

Thanks. I use the simulator but how do I take the code as it appears in Polyscope, either in the simulator or on the robot, to print just the Polyscope code? For example, the lines in the txt and script files are like this:
$ 747 “set_runstate_standard_digital_output_to_value(4, 0)”
set_runstate_standard_digital_output_to_value(4, 0)
which doubles the length. The duplication in the script file is removed by opening in VisualStudio but still can’t print the code. Troubleshooting someone else’s code is much faster for me if I can see the whole program.

Ah, right. You want the script code clean? But you’re also talking about programs from other people?

If you have a .urp file from the robot (file extension for UR programs), you will be able to open it in the PolyScope simulator, and it will look the same as on the physical robot.
I do this often when checking other people’s programs. And you will be able to make corrections and send the file back as .urp.

You can’t see a thousand lines of code on the Polyscope at once. It’s code from any of of our company’s robots being developed for clients but not written by me. I just need to be able to run through and jump around the code to find the problem without scrolling back and forth 20 lines at a time. I want to print the whole thing but not 2x plus all the blather from URCaps which is what you get with the txt or script file . Unfortunately sounds like I’d need to write a program to clean the file first.

There is no way to do what you are asking (view an entire program.urp in one continuous file that is printable and/or perusable). I know many of us in the UR applications team wish that this was possible.

I’ve done this once or twice and it requires a little bit of programming knowledge or some AI use.
BAsically what you can do is target lines that are irrelevant, usually they have a line number or some sort of tag that you can pinpoint as a pattern, - for example my code targets “$” and “#” and keeps them, checks if there are “if” statements, else, etc. and then plops it into Excel. It’s not something I reccomend over using the simulator.

Another approach in the simulator is remembering that there is in fact a serach function in the Program tab. I worked daily with the UR e-series for over a year before I noticed…

Thanks, I use search all the time and yes easy enough to strip out the extraneous with python or perl. The indent lines are handy so might just do a macro.

Its not perfect, but the strategy ive been using at least gets me some linting and var/func recognition in vscode. I use URScript - Visual Studio Marketplace. This will enable things like “Go To Definition” straight out of the box.

I personally use the “Outline” pane in VSCode. However; a raw script straight from the controller will only show one function in the outline: “{yourProgramName}”

To get outline pane to show all var, thread and func definitions;

  1. save your program, extract the .script
  2. Open the resulting script file in vscode
  3. remove “def {yourProgramName}():” from line 1
  4. remove “end” from last line
  5. right click > Format document

…now… URScript extension can recognize all var and func declarations and right click>Go To Definition works great.

Hadn’t seen that extension. Thanks!

you might also appreciate this:

Oh wait, I do have the URScript extension on VSCode. You still have lots of extra lines if you use a URCap for, say, a gripper. But it is better than the raw script or txt file. With a Print extension you can print but probably won’t want to when you see the code is now 4,269 lines.

Thanks, I’ll check it out.