Universal Robots Forum

Spiral Movement as URCaps PlugIn

Attached you find a small program that moves the robot along a helix-like path.
It is very simple, in a loop the waypoints are calculated, then the coordiantes are transformed from polar to cartesian coordinates using some sin and cos- relation. At the end the MoveP command is used to “send” the robot to the target position. The movement is stopped when the maximum angle e.g. 1440 degress is reached.
Right now it is pretty uncomfortable to change the area etc.

I don´t have much knowledge about URCaps but I have a running HelloWorldExample on my Virtual Machine.
My question is:
Would it take long time to “transform” the attached programm in to a URCaps Plugin where I can parameterize e.g the area that the helix will “use” etc.

spirale_changeDegrees.zip (3.1 KB)

Hi Michael

The simplest URCaps plugins to make, is the ones, where:

  1. You already have a UR-program or script code that has the desired functionality.
  2. You only contribute script code based on a few parameters, e.g an angle, speed or offset. .

So, this would be rather simple to implement in a URCap program node.
E.g. the URCap could just do the spiral movement from where-ever the robot is, when you insert the program node.
E.g. you would only need to implement the initialized variables and the Loop-statement.

Try to take a look at the UR3 Screw URCap sample, placed under samples.
This implements a pre-defined script, and just inserts a few parameters. Kind if what you are also aiming to do.


Sorry, there are so many samples folders, where do I find it. Can you please provide a link.
In the URCAP SDK I found only the HelloWorld and the MyDaemon Example.

You wrote: Kind if what you are aiming to do.
Sorry, my English is not perfect, you mean “Kind of what you are aiming to do” in the sense that the example is similar to what I imagine, right?

I meant “kind of…”, yes.
Take a look at these samples

@generalmidi this is exactly something that I was about to have to develop for an application we are deploying. We have a part that we are getting from a Graco flex feeder and then loading onto a spline. The part has a hole in the end that we are placing onto the spline. The issue is the part is cam shaped and the hole is not in the center. With the flex feeder we will have 4 possible orientations that the part will be in when we pick it up. A challenge we have is then to find the hole and quickly. The thought I had was to use something like this combined with the force mode to “find” the hole, similar to what Artemis is doing with their software. I took what you did and wrote a paramaterized URScript that you can just call in the program. This is the script that you would need to convert into a URCaps program node. Feel free to take the script that I wrote and use it for your cap.

Here is the script code

  def spiral(angleToStep, startRadius, maxAngle=100000, maxRadius=100000, a=.25, v=1.2):
  local R = startRadius
  local X = 0
  local Y = 0
  local pos = get_actual_tcp_pose()
  if maxAngle == 100000 and maxRadius == 100000:
    popup("Must specify either a max radius or max angle")
  local phi = angleToStep
  while phi < maxAngle and R < maxRadius:
      pos[1] = pos[1]+Y
      movep(pos, a=a, v=v)
  popup("Spiral has finished")


Thanks for the link to the UR3 Screw example. It helped me to get more into the structure of URCaps. I now use the Method generateScript to call my spiral script method.

public void generateScript(ScriptWriter writer) {

writer.appendLine("spiral(angleToStep, startRadius, ...Parameters)")

To find out more about the method that are available I now use Eclipse “IntelliSense”


Thanks for your help, we have modified our spiral slightly, e.g. to move in reverse , when it is finished as a URCap I can post it.

1 Like


You can either just pass the entire script code of the function inside the ProgramNode scriptWriter.
E.g., if ou have a function like:

def myFunc(speed, time):
   speedj([0,0,0,0,0,speed], 6, time)
   movel(...., 1.2, speed)

Then from your scriptWriter you could insert just the actual code;

   writer.appendLine("speedj([0,0,0,0,0,"+getSpeed()+"], 6, "+getTime()+")");
   writer.appendLine("movel(...., 1.2, "+getSpeed()+")");

Where e.g. getSpeed() would be a Java method to read the speed as string in radians from the DataModel.

Alternatively, you could use an InstallationNode to define the script function, and then use the ProgramNode to call the script function.
Hence, the generated script from your InstallationNode:

def myFunc(speed, time):
   speedj([0,0,0,0,0,speed], 6, time)
   movel(...., 1.2, speed)

And the ProgramNode could call: