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.

jbm

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")
    halt
  end 
  local phi = angleToStep
  while phi < maxAngle and R < maxRadius:
      phi=phi+angleToStep
      X=cos(d2r(phi))*R
      Y=sin(d2r(phi))*R
      pos[0]=pos[0]+X
      pos[1] = pos[1]+Y
      R=R+.001
      movep(pos, a=a, v=v)
      sync()
  end
  popup("Spiral has finished")
end
2 Likes

@jbm:

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.

@Override
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”

@mbush:

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

Michael,

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)
   .....
end

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)
   .....
end

And the ProgramNode could call:

writer.appendLine("myFunc("+getSpeed()+","+getTime()+")");