Making the robot draw variable circles using URscript

Hi,

I am creating a script that should allow the user to move the TCP to a position, and then select the radius of a circle to draw. Basically it would be a combination of Polyscope and URscript: the user creates a waypoint (that marks the beginning of the circle) and then calls the dCircle function described below.

I have tried to do this with both MoveC and MoveP but with unsatisfactory results.

Any comments and suggestions would be welcome.

MoveC:

def getRelativeTcp(x, y, z):

    tcp = get_actual_tcp_pose()
    tcp[0] = tcp[0] + x/1000
    tcp[1] = tcp[1] + y/1000
    tcp[2] = tcp[2] + z/1000

    return tcp

end

 #The user inputs radius and velocity

def dCircle(cRadius, velocity):                              

#Position at the topmost point of the circle, , in relation to the previous position

	pos1 = getRelativeTcp(cRadius, cRadius , 0)           

#Position at the rightmost point of the circle, in relation to the previous position

	pos2 = getRelativeTcp(cRadius, -cRadius, 0)         

#Here I try make the TCP move a half-moon to other side of the circle. For some reason I am not able to use other blend values than 1mm, meaning that the circle radius is not related to blend radius?

	movec(pos1, pos2, a=1, v=velocity, r= cRadius/1000, mode = 0) 

end

MoveP:

def getRelativeTcp(x, y, z):

    tcp = get_actual_tcp_pose()
    tcp[0] = tcp[0] + x/1000
    tcp[1] = tcp[1] + y/1000
    tcp[2] = tcp[2] + z/1000

    return tcp

end

def dCircle(cRadius, velocity):                              

#Position on the other side of the circle

	pos1 = getRelativeTcp(cRadius*2, 0, 0) 

#Trying to tell the robot to move to the position by blending a half-circle with the wished radius

       movep(pos, a=1.2, v=0.25, r=cRadius/1000)

end

I’ve had pretty good luck drawing variable circles using polar coordinates. You just teach the CENTER of the circle and then give a radius. Looked something like this (I’m pulling from memory, so you may need to tweak it):

r = radius //<---- get this information from the user
tcp = get_actual_tcp_pose()
theta = 0
while(theta <= 360)
  movep(p[rcos(theta), rsin(theta), tcp[z], 0, 0, 0], a=1.2, v=0.25, r=0.005)
  theta = theta +1
end

Because the robot operates in cartesional coordinates, you use the polar conversions to feed polar data into it
x = rcos(theta)
y = rsin(theta)
Then you just let theta range from 0 to 360 and it will make a full circle

You could also probably do some basic cartesional shifting if you wanted to teach say the top of the circle. You’d just apply a flat x or y shift by whatever the radius is.