Interpolate Joint in C#

Motion targets and interpolators can be tricky to control. I don’t see a clear error in your code that could cause turns to behave like that. SetAllJointTurns() should work and you set target matrix after that which is also correct. Some of the other properties that you set on the target might throw it off somehow. Could you test the function below to convert PTP statement into motion target and see if it makes a difference? I tested this snippet on 4.4 and for me it seemed to return correct joint positions for PTP when I had either default turns or some non-zero turns programmed into the PTP.

public void PtpStatementToMotionTarget(IJointMotionStatement stmt, ref IMotionTarget mt)
{
    mt.MotionType = MotionType.Joint;
    mt.SetAllJointValues(stmt.Positions[0].JointValues);    // This controls joint turns
    if (stmt.Base != null)
    {
        mt.BaseName = stmt.Base.Name;
    }
    else
    {
        mt.BaseName = "";
    }
    if (stmt.Tool != null)
    {
        mt.ToolName = stmt.Tool.Name;
    }
    else
    {
        mt.ToolName = "";
    }
    mt.ExternalTcp = stmt.ExternalTcp;
    mt.CurrentConfiguration = stmt.Configuration;
    mt.JointSpeed = stmt.JointSpeed * 100.0;
    mt.AccuracyMethod = stmt.AccuracyMethod;
    mt.AccuracyValue = stmt.AccuracyValue;
    mt.TargetMatrix = stmt.Positions[0].TransformationInReference;
}

-k

4 Likes