Jerk Limit
Currently, there are no parameters to set the jerk limit for path interpolation with look ahead.
However, a jerk limit can be applied by using the firstSmoothingTimeMilliseconds and secondSmoothingTimeMilliseconds parameters. These parameters will apply a 2-pass moving average filter on the commanded axes.
To enable the smoothing time parameters, set the setSmoothingTime parameter to TRUE.
The smoothing time parameters should be set as follows:
firstSmoothingTimeMilliseconds = 2 * 1000 * velocity limit / acceleration limit
secondSmoothingTimeMilliseconds = 2 * 1000 * acceleration limit / jerk limit
For example, if the velocity limit (set with velocityLimit) is 10000 and the desired acceleration limit is 200000 and the desired jerk limit is 8000000, the smoothing time parameters should be set as follows.
firstSmoothingTimeMilliseconds = 2 * 1000 * 10000 / 200000 = 100
secondSmoothingTimeMilliseconds = 2 * 1000 * 200000 / 8000000 = 50
The accLimit parameter can be set to 0 for axes for which the smoothing time parameters are set. The smoothing from the moving average filter will limit the acceleration according to the above equations. Setting the accLimit parameter to a nonzero value can increase the time it takes for the path interpolation with look ahead command to complete.
If all commanded axes have the smoothing time parameters set, the compositeAcc parameter can be set to the maximum value of 2^38-1 = 274877906943. The smoothing from the moving average filter will limit the acceleration according to the above equations. Setting the compositeAcc parameter to a smaller value can increase the time it takes for the path interpolation with look ahead command to complete.
These parameters will change and smooth out the shape of the path. Decreasing the value of these parameters will reduce the amount of smoothing and make the shape of the path closer to the commanded path.
To decrease firstSmoothingTimeMilliseconds without changing the acceleration limit or the jerk limit, the velocityLimit must be decreased by the same ratio. This will increase the time it takes for the path interpolation with look ahead command to complete.
Otherwise, decreasing the firstSmoothingTimeMilliseconds will increase the acceleration limit and jerk limit.
Decreasing the secondSmoothingTimeMilliseconds will increase just the jerk limit.
Example 1: Base Case
The following is an example path interpolation with look ahead command. The smoothing time parameters are not yet enabled.
AdvMotion::PathIntplLookaheadConfiguration config;
AdvMotion::PathIntplLookaheadCommand path;
int i;
//Set configuration data
config.axisCount = 2;
config.axis[0] = 0;
config.axis[1] = 1;
config.compositeVel = 100000;
config.compositeAcc = 1000000;
config.sampleDistance = 1;
//Set velocity and acceleration limits
config.velocityLimit[0] = 10000;
config.velocityLimit[1] = 10000;
config.accLimit[0] = 200000;
config.accLimit[1] = 200000;
//Set point data
path.numPoints = 10;
for (i = 0; i < path.numPoints; i++) {
path.point[i].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[i].data.linear.axisCount = 2;
path.point[i].data.linear.axis[0] = 0;
path.point[i].data.linear.axis[1] = 1;
}
path.point[0].data.linear.target[0] = 0 + 1000/tan((double)32.5/360*2*M_PI);
path.point[0].data.linear.target[1] = 1000;
path.point[1].data.linear.target[0] = path.point[0].data.linear.target[0] + 1000/tan((double)32.5/360*2*M_PI);
path.point[1].data.linear.target[1] = 0;
path.point[2].data.linear.target[0] = path.point[1].data.linear.target[0] + 1000/tan((double)45/360*2*M_PI);
path.point[2].data.linear.target[1] = 1000;
path.point[3].data.linear.target[0] = path.point[2].data.linear.target[0] + 1000/tan((double)45/360*2*M_PI);
path.point[3].data.linear.target[1] = 0;
path.point[4].data.linear.target[0] = path.point[3].data.linear.target[0] + 1000/tan((double)67.5/360*2*M_PI);
path.point[4].data.linear.target[1] = 1000;
path.point[5].data.linear.target[0] = path.point[4].data.linear.target[0] + 1000/tan((double)67.5/360*2*M_PI);
path.point[5].data.linear.target[1] = 0;
path.point[6].data.linear.target[0] = path.point[5].data.linear.target[0] + 1000/tan((double)75/360*2*M_PI);
path.point[6].data.linear.target[1] = 1000;
path.point[7].data.linear.target[0] = path.point[6].data.linear.target[0] + 1000/tan((double)75/360*2*M_PI);
path.point[7].data.linear.target[1] = 0;
path.point[8].data.linear.target[0] = path.point[7].data.linear.target[0] + 1000/tan((double)80/360*2*M_PI);
path.point[8].data.linear.target[1] = 1000;
path.point[9].data.linear.target[0] = path.point[8].data.linear.target[0] + 1000/tan((double)80/360*2*M_PI);
path.point[9].data.linear.target[1] = 0;
//Call API functions
wmxlib_AdvancedMotion->advMotion->CreatePathIntplLookaheadBuffer(0, 50000);
wmxlib_AdvancedMotion->advMotion->SetPathIntplLookaheadConfiguration(0, &config);
wmxlib_AdvancedMotion->advMotion->AddPathIntplLookaheadCommand(0, &path);
wmxlib_AdvancedMotion->advMotion->StartPathIntplLookahead(0);
The following plots show the 2D position, velocity, acceleration, jerk of each axis when the above sequence is executed from position (0, 0).

The motion stops after each linear interpolation segment.
The velocity limit is 10000 units/s and the acceleration limit is 100000 units/s^2. The velocity limit and acceleration limit are not exceeded, but the jerk spikes to over 200000000 units/s^3.
The execution time is 1615ms.
Example 2: Smooth Radius
The path can be smoothed by setting the smooth radius. This will insert circular interpolation segments between linear interpolation segments so that there are no sharp corners in the path.
The latter half of the sample code is omitted for brevity as it is the same for all examples.
AdvMotion::PathIntplLookaheadConfiguration config;
AdvMotion::PathIntplLookaheadCommand path;
int i;
//Set configuration data
config.axisCount = 2;
config.axis[0] = 0;
config.axis[1] = 1;
config.compositeVel = 100000;
config.compositeAcc = 1000000;
config.sampleDistance = 1;
//Set velocity and acceleration limits
config.velocityLimit[0] = 10000;
config.velocityLimit[1] = 10000;
config.accLimit[0] = 200000;
config.accLimit[1] = 200000;
//Set point data
path.numPoints = 10;
for (i = 0; i < path.numPoints; i++) {
path.point[i].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[i].data.linear.axisCount = 2;
path.point[i].data.linear.axis[0] = 0;
path.point[i].data.linear.axis[1] = 1;
path.point[i].data.linear.smoothRadius = 200;
}
The following plots show the 2D position, velocity, acceleration, jerk of each axis when the above sequence is executed from position (0, 0).

The motion no longer stops after each linear interpolation segment.
The velocity limit and acceleration limit are not exceeded, but the jerk still spikes to over 200000000 units/s^3.
The execution time is 1400ms.
Example 3: Smoothing Time
We will now enable smoothing time. The smooth radius is disabled so that the effects of smoothing time can be compared with the smooth radius.
We will set the jerk limit to 8000000 units/s^3. Following the equations at the top of this page, the first smoothing time is calculated to be 100ms and the second smoothing time is calculated to be 50ms.
firstSmoothingTimeMilliseconds = 2 * 1000 * 10000 / 200000 = 100
secondSmoothingTimeMilliseconds = 2 * 1000 * 200000 / 8000000 = 50
When setting the smoothing time, the compositeAcc can be set to the maximum value of 2^38-1 = 274877906943 and the accLimitcan be set to 0 as the smoothing time will apply the acceleration limit instead.
AdvMotion::PathIntplLookaheadConfiguration config;
AdvMotion::PathIntplLookaheadCommand path;
int i;
//Set configuration data
config.axisCount = 2;
config.axis[0] = 0;
config.axis[1] = 1;
config.compositeVel = 100000;
config.compositeAcc = 274877906943;
config.sampleDistance = 1;
//Set velocity and acceleration limits
config.velocityLimit[0] = 10000;
config.velocityLimit[1] = 10000;
config.accLimit[0] = 0;
config.accLimit[1] = 0;
//Set smoothing time
config.setSmoothingTime = true;
config.firstSmoothingTimeMilliseconds[0] = 100;
config.firstSmoothingTimeMilliseconds[1] = 100;
config.secondSmoothingTimeMilliseconds[0] = 50;
config.secondSmoothingTimeMilliseconds[1] = 50;
//Set point data
path.numPoints = 10;
for (i = 0; i < path.numPoints; i++) {
path.point[i].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[i].data.linear.axisCount = 2;
path.point[i].data.linear.axis[0] = 0;
path.point[i].data.linear.axis[1] = 1;
}
The following plots show the 2D position, velocity, acceleration, jerk of each axis when the above sequence is executed from position (0, 0).

The velocity limit and acceleration limit are not exceeded, and the jerk is also limited to 8000000 units/s^3.
However, the shape of the path is significantly changed.
The execution time is 1265ms.
Example 4: Smoothing Time (Reduce Velocity)
In the previous example, the shape of the path was significantly changed.
To reduce the change to the shape of the path, the smoothing times must be reduced. One way to do so without changing the acceleration limit and jerk limit is to reduce the velocity limit. This will increase the execution time.
To reduce the first smoothing time from 100ms to 80ms, the velocity limit must be reduced by the same ratio, from 10000 units/s to 8000 units/s.
The first smoothing time and second smoothing time are calculated as follows.
firstSmoothingTimeMilliseconds = 2 * 1000 * 8000 / 200000 = 80
secondSmoothingTimeMilliseconds = 2 * 1000 * 200000 / 8000000 = 50
AdvMotion::PathIntplLookaheadConfiguration config;
AdvMotion::PathIntplLookaheadCommand path;
int i;
//Set configuration data
config.axisCount = 2;
config.axis[0] = 0;
config.axis[1] = 1;
config.compositeVel = 100000;
config.compositeAcc = 274877906943;
config.sampleDistance = 1;
//Set velocity and acceleration limits
config.velocityLimit[0] = 8000;
config.velocityLimit[1] = 8000;
config.accLimit[0] = 0;
config.accLimit[1] = 0;
//Set smoothing time
config.setSmoothingTime = true;
config.firstSmoothingTimeMilliseconds[0] = 80;
config.firstSmoothingTimeMilliseconds[1] = 80;
config.secondSmoothingTimeMilliseconds[0] = 50;
config.secondSmoothingTimeMilliseconds[1] = 50;
//Set point data
path.numPoints = 10;
for (i = 0; i < path.numPoints; i++) {
path.point[i].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[i].data.linear.axisCount = 2;
path.point[i].data.linear.axis[0] = 0;
path.point[i].data.linear.axis[1] = 1;
}
The following plots show the 2D position, velocity, acceleration, jerk of each axis when the above sequence is executed from position (0, 0).

Compared to the previous example, the shape of the path is changed less.
The execution time is 1524ms, which is longer than even the smooth radius example. However, compared to the smooth radius example, the jerk is limited to 8000000 units/s^3 and not spiking to over 200000000 units/s^3.
Example 5: Smoothing Time (Increase Acceleration Limit and Jerk Limit)
Another way to reduce the smoothing time and reduce the change to the shape of the path is to increase the acceleration limit and jerk limit.
To reduce the first smoothing time from 100ms to 80ms, the acceleration limit and jerk limit must be increased by the inverse of the ratio, 100/80 = 1.25x. The acceleration limit is increased from 200000 to 250000 units/s^2 and the jerk limit is increased from 8000000 to 10000000 units/s^3.
The first smoothing time and second smoothing time are calculated as follows.
firstSmoothingTimeMilliseconds = 2 * 1000 * 10000 / 250000 = 80
secondSmoothingTimeMilliseconds = 2 * 1000 * 250000 / 10000000 = 50
AdvMotion::PathIntplLookaheadConfiguration config;
AdvMotion::PathIntplLookaheadCommand path;
int i;
//Set configuration data
config.axisCount = 2;
config.axis[0] = 0;
config.axis[1] = 1;
config.compositeVel = 100000;
config.compositeAcc = 274877906943;
config.sampleDistance = 1;
//Set velocity and acceleration limits
config.velocityLimit[0] = 10000;
config.velocityLimit[1] = 10000;
config.accLimit[0] = 0;
config.accLimit[1] = 0;
//Set smoothing time
config.setSmoothingTime = true;
config.firstSmoothingTimeMilliseconds[0] = 80;
config.firstSmoothingTimeMilliseconds[1] = 80;
config.secondSmoothingTimeMilliseconds[0] = 50;
config.secondSmoothingTimeMilliseconds[1] = 50;
//Set point data
path.numPoints = 10;
for (i = 0; i < path.numPoints; i++) {
path.point[i].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[i].data.linear.axisCount = 2;
path.point[i].data.linear.axis[0] = 0;
path.point[i].data.linear.axis[1] = 1;
}
The following plots show the 2D position, velocity, acceleration, jerk of each axis when the above sequence is executed from position (0, 0).

Like the previous example, the shape of the path is changed less.
The acceleration reaches a higher 250000 units/s^2 and the jerk reaches a higher 10000000 units/s^3.
The execution time is 1245ms.
Example 6: Smoothing Time (Increase Only Jerk Limit)
Another way to reduce the smoothing time and reduce the change to the shape of the path is to increase just the jerk limit. This will reduce the second smoothing time.
To reduce the second jerk limit from 50ms to 40ms, the jerk limit must be increased by the inverse of the ratio, 50/40 = 1.25x. The jerk limit is increased from 8000000 to 10000000 units/s^3.
The first smoothing time and second smoothing time are calculated as follows.
firstSmoothingTimeMilliseconds = 2 * 1000 * 10000 / 200000 = 100
secondSmoothingTimeMilliseconds = 2 * 1000 * 200000 / 10000000 = 40
AdvMotion::PathIntplLookaheadConfiguration config;
AdvMotion::PathIntplLookaheadCommand path;
int i;
//Set configuration data
config.axisCount = 2;
config.axis[0] = 0;
config.axis[1] = 1;
config.compositeVel = 100000;
config.compositeAcc = 274877906943;
config.sampleDistance = 1;
//Set velocity and acceleration limits
config.velocityLimit[0] = 10000;
config.velocityLimit[1] = 10000;
config.accLimit[0] = 0;
config.accLimit[1] = 0;
//Set smoothing time
config.setSmoothingTime = true;
config.firstSmoothingTimeMilliseconds[0] = 100;
config.firstSmoothingTimeMilliseconds[1] = 100;
config.secondSmoothingTimeMilliseconds[0] = 40;
config.secondSmoothingTimeMilliseconds[1] = 40;
//Set point data
path.numPoints = 10;
for (i = 0; i < path.numPoints; i++) {
path.point[i].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[i].data.linear.axisCount = 2;
path.point[i].data.linear.axis[0] = 0;
path.point[i].data.linear.axis[1] = 1;
}
The following plots show the 2D position, velocity, acceleration, jerk of each axis when the above sequence is executed from position (0, 0).

Like the previous example, the shape of the path is changed less.
The jerk reaches a higher 10000000 units/s^3.
The execution time is 1255ms.
Example 7: Smoothing Time (One Pass)
An alternate method is to use only one of the smoothing times. This will effectively apply a one-pass moving average filter instead of a two-pass moving average filter.
This will apply a jerk limit, provided that the acceleration limit is applied by some other means. In other words, the accLimit must be set once again. (If the acceleration limit is not applied before the moving average filter is applied, the moving average filter will apply the acceleration limit but not the jerk limit.)
The acceleration limit is set to 200000 units/s^2 and the jerk limit is set to 8000000 units/s^3.
The first smoothing time is set to 0. The second smoothing time is calculated as follows.
secondSmoothingTimeMilliseconds = 2 * 1000 * 200000 / 8000000 = 50
AdvMotion::PathIntplLookaheadConfiguration config;
AdvMotion::PathIntplLookaheadCommand path;
int i;
//Set configuration data
config.axisCount = 2;
config.axis[0] = 0;
config.axis[1] = 1;
config.compositeVel = 100000;
config.compositeAcc = 1000000;
config.sampleDistance = 1;
//Set velocity and acceleration limits
config.velocityLimit[0] = 10000;
config.velocityLimit[1] = 10000;
config.accLimit[0] = 200000;
config.accLimit[1] = 200000;
//Set smoothing time
config.setSmoothingTime = true;
config.firstSmoothingTimeMilliseconds[0] = 0;
config.firstSmoothingTimeMilliseconds[1] = 0;
config.secondSmoothingTimeMilliseconds[0] = 50;
config.secondSmoothingTimeMilliseconds[1] = 50;
//Set point data
path.numPoints = 10;
for (i = 0; i < path.numPoints; i++) {
path.point[i].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[i].data.linear.axisCount = 2;
path.point[i].data.linear.axis[0] = 0;
path.point[i].data.linear.axis[1] = 1;
}
The following plots show the 2D position, velocity, acceleration, jerk of each axis when the above sequence is executed from position (0, 0).

The shape of the path is changed, but only by a small amount.
The execution time is 1665ms, which is slightly longer than the base case in which the axes stopped after each linear interpolation. However, compared to the base case, the jerk is limited to 8000000 units/s^3 instead of spiking to over 200000000 units/s^3.
Example 8: Smoothing Time (One Pass) with Smooth Radius
To improve the execution time with a one-pass moving average filter, the smooth radius can be set.
This example is the same as the previous example, except the smooth radius is set to 200.
AdvMotion::PathIntplLookaheadConfiguration config;
AdvMotion::PathIntplLookaheadCommand path;
int i;
//Set configuration data
config.axisCount = 2;
config.axis[0] = 0;
config.axis[1] = 1;
config.compositeVel = 100000;
config.compositeAcc = 1000000;
config.sampleDistance = 1;
//Set velocity and acceleration limits
config.velocityLimit[0] = 10000;
config.velocityLimit[1] = 10000;
config.accLimit[0] = 200000;
config.accLimit[1] = 200000;
//Set smoothing time
config.setSmoothingTime = true;
config.firstSmoothingTimeMilliseconds[0] = 0;
config.firstSmoothingTimeMilliseconds[1] = 0;
config.secondSmoothingTimeMilliseconds[0] = 50;
config.secondSmoothingTimeMilliseconds[1] = 50;
//Set point data
path.numPoints = 10;
for (i = 0; i < path.numPoints; i++) {
path.point[i].type = AdvMotion::PathIntplLookaheadSegmentType::Linear;
path.point[i].data.linear.axisCount = 2;
path.point[i].data.linear.axis[0] = 0;
path.point[i].data.linear.axis[1] = 1;
path.point[i].data.linear.smoothRadius = 200;
}
The following plots show the 2D position, velocity, acceleration, jerk of each axis when the above sequence is executed from position (0, 0).

The shape of the path is changed by the smooth radius and additionally a small amount from the smoothing time.
The execution time is 1450ms.