My lack of math skills is currently on display...
I have a CSV file that has XYZ values as well as three vectors (ijk of each). The code snippet below will read the lines and create targets. The targets look as expected - the AddTarget method takes care of the required coordinate system.
However, I do NOT want a couple thousand targets so I need to create the MoveL instructions from the script without targets. That means, I think, that I have to move the pose as read from the file to the reference frame myself. My attempt has failed and the script is creating targets on the other side of the robot that apparently are not reachable.
How do I move the coordinates from the robot base (world CS) to the reference frame?
This is how to NOT do it:
positionInFrame = matrix * framePose
I have a CSV file that has XYZ values as well as three vectors (ijk of each). The code snippet below will read the lines and create targets. The targets look as expected - the AddTarget method takes care of the required coordinate system.
However, I do NOT want a couple thousand targets so I need to create the MoveL instructions from the script without targets. That means, I think, that I have to move the pose as read from the file to the reference frame myself. My attempt has failed and the script is creating targets on the other side of the robot that apparently are not reachable.
How do I move the coordinates from the robot base (world CS) to the reference frame?
This is how to NOT do it:
positionInFrame = matrix * framePose
Code:
<snip>
Frame = Robot.getLink(robolink.ITEM_TYPE_FRAME)
Tool = Robot.getLink(robolink.ITEM_TYPE_TOOL)
framePose = Frame.PoseAbs()
for n in range( len(AllLines) ):
Line = AllLines[n]
print(f'Line {n} --> {Line}')
Pieces = Line.strip().split(',')
try:
x = float( Pieces[0].strip() )
y = float( Pieces[1].strip() )
z = float( Pieces[2].strip() )
V1i = float( Pieces[3].strip() )
V1j = float( Pieces[4].strip() )
V1k = float( Pieces[5].strip() )
V2i = float( Pieces[6].strip() )
V2j = float( Pieces[7].strip() )
V2k = float( Pieces[8].strip() )
V3i = float( Pieces[9].strip() )
V3j = float( Pieces[10].strip() )
V3k = float( Pieces[11].strip() )
# These targets are in the correct position
matrix = robomath.Mat(rows=4, ncols=4)
matrix = matrix.setPos([x,y,z])
matrix = matrix.setVX([V2i, V2j, V2k])
matrix = matrix.setVY([V3i, V3j, V3k])
matrix = matrix.setVZ([V1i, V1j, V1k])
newTarget = RDK.AddTarget(f'Index {n}', Frame, Robot)
newTarget.setPose(matrix)
# Convert from World CS to work object CS
positionInFrame = matrix * framePose
NewProgram.MoveL(positionInFrame)
except Exception as Err:
print(f'Error on line {n+1} of the CSV file:')
print( str(Err) )