Linear Interpolation

A linear interpolation command interpolates the cyclic position commands of one or more axes to move in a straight line in 2D, 3D, or other dimensional space. There is no limit to the number of axes that may be commanded by a single linear interpolation command.

In a basic linear interpolation command, the axes to command, the target positions of the axes, and the motion profile along the interpolation trajectory are specified.

Linear Interpolation Example

The following code executes a simple 2D linear interpolation command.

Motion::LinearIntplCommand lin;

lin.axisCount = 2;
lin.axis[0] = 0;
lin.axis[1] = 1;

lin.profile.type = ProfileType::Trapezoidal;
lin.profile.velocity = 10000;
lin.profile.acc = 10000;
lin.profile.dec = 10000;

lin.target[0] = 30000;
lin.target[1] = 10000;

wmxlib_CoreMotion->motion->StartLinearIntplPos(&lin);

The following plots show the positions and velocities when the above code is executed.

../_images/WMXDOC_FUNC_INT_LINEAR_image0.png

Axis Limit Linear Interpolation Profile Calculation Mode

Because the motion profile along the interpolation trajectory is specified, it can be difficult to predict the velocities and accelerations of the individual axes during interpolation.

If the Linear Intpl Profile Calc Mode parameter is set to AxisLimit (the default value of this parameter), the Max Velocity, Max Acc, and Max Dec parameters can limit the velocities, acceleration, and deceleration of individual axes to certain maximum values. (Max Jerk Acc and Max Jerk Dec can also be specified for profile types with jerk parameters.)

The following code executes the same 2D linear interpolation command as the previous example, but sets the maximum velocity of axis 0 to 6000 user units per second.

Motion::LinearIntplCommand lin;

lin.axisCount = 2;
lin.axis[0] = 0;
lin.axis[1] = 1;

lin.profile.type = ProfileType::Trapezoidal;
lin.profile.velocity = 10000;
lin.profile.acc = 10000;
lin.profile.dec = 10000;

lin.target[0] = 30000;
lin.target[1] = 10000;

lin.maxVelocity[0] = 6000;

wmxlib_CoreMotion->motion->StartLinearIntplPos(&lin);

The following plots show the positions and velocities when the above code is executed.

../_images/WMXDOC_FUNC_INT_LINEAR_image1.png

If the maximum velocity of at least one interpolating axis is specified, the velocity of the motion profile along the interpolation trajectory can be omitted. In this case, the velocity along the trajectory is entirely determined by the maximum velocity of the interpolating axes. Similarly, the profile acceleration, deceleration, jerk acceleration, and jerk deceleration can be omitted if the maximum values of these parameters is specified for at least one interpolating axis.

The following code executes the same 2D linear interpolation command as the previous example, but does not specify the profile velocity.

Motion::LinearIntplCommand lin;

lin.axisCount = 2;
lin.axis[0] = 0;
lin.axis[1] = 1;

lin.profile.type = ProfileType::Trapezoidal;
lin.profile.acc = 10000;
lin.profile.dec = 10000;

lin.target[0] = 30000;
lin.target[1] = 10000;

lin.maxVelocity[0] = 6000;

wmxlib_CoreMotion->motion->StartLinearIntplPos(&lin);

The position and velocity plots are the same as the previous example.

Match Slowest Axis Linear Interpolation Profile Calculation Mode

If the Linear Intpl Profile Calc Mode parameter is set to MatchSlowestAxis, the velocity, acceleration, deceleration, jerk acceleration, and jerk deceleration of the motion profile along the interpolation trajectory cannot be specified. Instead, these parameters are specified for at least one of the interpolating axes. Of the axes for which these parameters are specified, the axis that would cause the interpolation velocity to be the slowest is chosen, and all other interpolating axes will follow that axis.

The following code executes a 2D linear interpolation with a different velocity parameter specified for the two axes.

Motion::LinearIntplCommand lin;
Trigger trig;

lin.axisCount = 2;
lin.axis[0] = 0;
lin.axis[1] = 1;

lin.profile.type = ProfileType::Trapezoidal;

lin.target[0] = 30000;
lin.target[1] = 10000;

lin.maxVelocity[0] = 16000;
lin.maxVelocity[1] = 5000;

lin.maxAcc[0] = 10000;
lin.maxAcc[1] = 10000;

lin.maxDec[0] = 10000;
lin.maxDec[1] = 10000;

wmxlib_CoreMotion->motion->StartLinearIntplPos(&lin);

The following plots show the positions and velocities when the above code is executed with the Linear Intpl Profile Calc Mode parameter set to MatchSlowestAxis.

../_images/WMXDOC_FUNC_INT_LINEAR_image2.png

Match Farthest Axis Linear Interpolation Profile Calculation Mode

If the Linear Intpl Profile Calc Mode parameter is set to MatchFarthestAxis, like MatchSlowestAxis, the velocity, acceleration, deceleration, jerk acceleration, and jerk deceleration of the motion profile along the interpolation trajectory cannot be specified. Instead, these parameters are specified for at least one of the interpolating axes. Of the axes for which these parameters are specified, the axis that is farthest from its target position is chosen, and all other interpolating axes will follow that axis.

The following code executes a 2D linear interpolation with a different velocity parameter specified for the two axes. This code is identical to the previous example, but will be executed with the MatchFarthestAxis parameter instead of MatchSlowestAxis.

Motion::LinearIntplCommand lin;
Trigger trig;

lin.axisCount = 2;
lin.axis[0] = 0;
lin.axis[1] = 1;

lin.profile.type = ProfileType::Trapezoidal;

lin.target[0] = 30000;
lin.target[1] = 10000;

lin.maxVelocity[0] = 16000;
lin.maxVelocity[1] = 5000;

lin.maxAcc[0] = 10000;
lin.maxAcc[1] = 10000;

lin.maxDec[0] = 10000;
lin.maxDec[1] = 10000;

wmxlib_CoreMotion->motion->StartLinearIntplPos(&lin);

The following plots show the positions and velocities when the above code is executed with the Linear Intpl Profile Calc Mode parameter set to MatchFarthestAxis.

../_images/WMXDOC_FUNC_INT_LINEAR_image3.png