Universal Robots Forum

Is there a general guide for the UR e-series on controlling the coBot via languages different from URScript?

Browsing this Forum, I’ve come across people who use java or python to program their CoBot. I however don’t have a clue how this is done, so in this question I want to ask for all the general ways on how to do that.

The scope of this question is only the UR e-Series (my company employs an e-5).

As I understand it, the coBot naturally comes with polyscope (which is a GUI for URScript). UR-Script is the language that runs on the CoBot Hardware, and for that language I can also write Scripts and transfer them to the coBot before execution via an USB-device.

I hope everything that I stated up until here is correct - if it’s not, please correct me.

So now I’m asking - what if I’d like to program in a language that is more capable than UR-Script - What do I have to do? Is it right that I then have to use one of the interfaces that is mentioned here: Overview of client interfaces - 21744? Is this the only way?

The other way I see is to set variables via the TCP connection:

All the options seem cumbersome to me (but that is of course because I didn’t really look into it yet). Which route should I pursue as a beginner here?

As a new-ish, 95% self-taught user myself I think the Polyscope GUI is a pretty good way to get started and get used to the robot. You can mix in python or other scripts via that GUI as you get more comfortable.

The other methods you mention are possible but there are varying degrees of difficulty in learning them if you’re not already familiar with how they work. Also, I think the best choice might be based on your application, what you’re doing with the robot.

I do fairly basic machine tending using two UR10e’s in a 3 axis and a 5 axis machining center. I change parts weekly and add new parts almost monthly so I spend a lot of time programming in Polyscope. We’re not connected to the network so file management is a PITA but I am considering a change there soon for reasons you can see here.

Hi Ansgar.

The final robot control is as far as I have understood always URScript. even if you are using java or python.
If you are using Java or Python you are “just” using these language to stitch together a URScript in clever way or calling multiple URscripts in a equally clever way.

So no matter what you will have to learn URscript as it is the baiscs of controlling a UR arm.

I think I’ve learned quite a bit URScript already. Can you explain in more detail how Java and Python would be used to “stitch” together the URScript code?

Can you explain to me in more detail how you “mix in python via that GUI”? As far as I understood, UR-Script is the language that runs on the machine (and there is no python interpreter running).
Where in the GUI do I have the option to call foreign code (and possible give arguments)?

You would write your code in your language of choice, then in Polyscope you would use the Advanced section and insert a Script node. The script node can be a single line of code that you type in the box, or you can select File from the drop down and point it to your script. When the robot program gets to that node it will interpret the script and execute it.

Up until now I thought the script file also must contain URScript code. Why would it work with any code?

I believe there is an interpreter in Polyscope.

This is interesting, I’ll look into it. Thank you

I’m not 100% sure what you mean, but I’ll try my best (I am also new):

  • Yes, UR Script is the main language for programming a UR arm. To me it is quite similar to Python and Matlab languages, so if you have experience with it, you’ll learn fast. But compared to them, it is much more limited, and I ran also into some limitations.
    However, to send scripts and execute them remotely, you can use the Dashboard Server and the connection is done in TCP using the port 2999 and the controller IP address. Then from your remote program you can use any language to load a program and execute. In Python for example:
import socket
import sys
import time
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
robot_address = ('', 29999)
# You need to re-start the connection everytime you send a command
# 1. load program
sock.connect(robot_address)	# connect
sock.sendall(b'load my_program.urp')		# send
dataRaw = sock.recv(1024)	# receive
sock.close()			# disconnect
# 2. run
sock.connect(robot_address)	# connect
sock.sendall(b'play')		# send
dataRaw = sock.recv(1024)	# receive
sock.close()			# disconnect
  • Yes, you can include in Polyscope Java and Python processes, but not directly. The Script option in Polyscope is only for URScript language (see [1]), so if you want to use any other language, it must run as a parallel process. To do so, you need to create a URCap, which is done in Java and compiled in .urcap format in order to be installed in Polyscope. To add extra functionalities or combine different languages, you’ll have to program your URCap to run a daemon process, which can be in Java, Python or even C++, so in your case you could access to USB ports or do any other functionality that is limited/inexistent in URScript.
    My first URCap tutorial
    However, I have struggled a lot with daemon processes in Polyscope, since you need additional settings on your URCap project and stablish an internal communication between the URCap and the daemon process through XML-RPC.
    Here there is an example of this type of URCap using a daemon process to set a MODBUS serial communication between the arm and a tool: MODBUS URCap repo

As a fellow beginner, I’d recommend you the Dashboard Server option, and if you cannot access the robot network and you have only a USB, try to set an executable program on the USB that connects to the Dashboard Server (because since the process is launched within the same computer, it will connect). I’d not recommend go for a URCap.

[1]: I have looked into one of the previous answers about using the Script option in Polyscope for different languages, and I tried to use with python and C++ files and it didn’t work. So I don’t think that the interpreter works outside Script language.