Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Create targets based on tool position


Im trying to make a program that can automatically add targets to RoboDK based on the tool position.
I am stuck in translating the rotation into my targets.

ref_frame = kuka.Pose()
pos_ref = ref_frame.Pos()

#targets = np.array([[0]*3]*len(xcoordinates))
targets = []
target = np.array([])

for i in range(0, len(xcoordinates)):
   target = transl(ycoordinates[i], xcoordinates[i], 0)*pos_ref

prog = RDK.AddProgram('ForwardAuto')
prog.setSpeed(speed_linear=speed, accel_linear=accel)

for i in range(0, len(targets)):
   ti = RDK.AddTarget('AutoTarget %i' % (i + 1))
   pose_i = ref_frame
The list of coordinates is very simple, its split in 2 seperate arrays. the list is increasing and supposed to be from left to right. translated for the first position to be 0,0
example: xcoordinates = [0, 10, 30, 40, 50], ycoordinates = [0, 1, 3, 1, -1]
This works fine, but when i rotate the robot my targets are placed in the wrong direction. so i want to either correctly translate the targets to just follow the tool coordinate system, i think this is the correct approach. Or i want to be able to translate the targets to be -1 when the base axis is over a treshhold.

a picture to show the setup in roboDK is attached

You can see the positive direction of the kuka frame is to the left, but i want to add points going to the right. You can also see the many points created going from the start towards the left, instead of to the right to finish.
If you want to make movements relative to the current robot pose you should replace this line:

target = transl(ycoordinates[i], xcoordinates[i], 0)*pos_ref

By this one:

target = transl(ycoordinates[i], xcoordinates[i], 0)*ref_frame

The first one translates a point while the second one translates the pose.
When i replace that line, i get an error message.

self[0, 3] = newpos[0]

raise Exception(MatrixError, "Submatrix indices does not match the new matrix sizes", itmsz[0], "x", itmsz[1], "<-", newm, "x", newn)
Exception: (<class 'robodk.robomath.MatrixError'>, 'Submatrix indices does not match the new matrix sizes', 1, 'x', 4, '<-', range(0, 1), 'x', range(3, 4))

Users browsing this thread:
1 Guest(s)