RobotStudio event

RS SDK - Tool Compensation



Hi there,
 
I am wanting to implement a path offset in the same way as the "Path -- Tool Compensation" feature works (i.e. offset the path to compensate for the radius of the tool).  Unfortunately, I'm tying myself in knots with the various Frames, Transforms and Matrices that are involved!
 
So...
 
RsTarget.Transform
 
...gives me the coordinates for the target in the local work object, and...
 
RsTarget.ReferenceFrame
 
...gives me the coordinates for the target in the target reference frame.  I seem to be able to move the ReferenceFrame by using...
 
// I want to offset the target by 20mm in the Y-direction of the ReferenceFrame
Matrix4 offsetMatrix = new Matrix4(new Vector3(0, 0.02, 0), new Vector3(0, 0, 0));
target.ReferenceFrame.SetRelativeTransform(target.Transform.GlobalMatrix, offsetMatrix);
 
...but this doesn't move the actual target point at all.
 
Am I on the right track?  How do I move this target to the required location?
 
Many thanks! 

Comments



  • Bump.


  • I think I've answered my own question (which hopefully somebody can confirm).  Here's the solution that I've come up with...
     
    // Record the rotation vector of the current target
    Vector3 oldRotationVector = target.Transform.Matrix.EulerZYX;
     
    // I want to offset the target by 20mm in the Y-direction of the ReferenceFrame
    Matrix4 offsetMatrix = new Matrix4(new Vector3(0, 0.02, 0), new Vector3(0, 0, 0));
     
    // Translate the target in the reference frame, although this ends up with the wrong orientation
    target.Transform.SetRelativeTransfom(target.ReferenceFrame.GlobalMatrix, offsetMatrix);
     
    // Record this new translation vector
    Vector3 newTranslationVector = target.Transform.Matrix.Translation;
     
    // Set the target matrix to the new translation and the old rotation
    target.Transform.Matrix = new Matrix4(newTranslationVector, oldRotationVector);
     
    This seems to work and gives results consistent with the "Tool Compensation" functionality.