Interpolation without XY Rotational Motion

The following sample code executes a simple path interpolation with rotation sequence consisting of four linear interpolations. The option to disable rotating the X and Y axes around the center of rotation (disableXYRotationalMotion) is enabled.

//Create the path interpolation with rotation buffer
wmxlib_AdvancedMotion->advMotion->CreatePathIntplWithRotationBuffer(0, 1000);

//Configure the path interpolation with rotation channel
AdvMotion::PathIntplWithRotationConfiguration conf;

conf.axis[0] = 0; //X axis
conf.axis[1] = 1; //Y axis
conf.rotationalAxis = 2; //Rotational axis
conf.centerOfRotation[0] = 500; //X axis center of rotation position
conf.centerOfRotation[1] = 500; //Y axis center of rotation position

//Rotational axis angle correction motion profile parameters
conf.angleCorrectionProfile.type = ProfileType::Trapezoidal;
conf.angleCorrectionProfile.velocity = 90;
conf.angleCorrectionProfile.acc = 180;
conf.angleCorrectionProfile.dec = 180;

//Disable rotating the X and Y axes around the center of rotation when the rotational axis moves
conf.disableXYRotationalMotion = 1;

wmxlib_AdvancedMotion->advMotion->SetPathIntplWithRotationConfiguration(0, &conf);

//Add the path interpolation with rotation commands
AdvMotion::PathIntplWithRotationCommand path;

path.numPoints = 4;

path.point[0].type = AdvMotion::PathIntplSegmentType::Linear;
path.point[0].profile.type = ProfileType::Trapezoidal;
path.point[0].profile.velocity = 1000;
path.point[0].profile.acc = 2000;
path.point[0].profile.dec = 2000;
path.point[0].target[0] = 1000;
path.point[0].target[1] = 0;

path.point[1].type = AdvMotion::PathIntplSegmentType::Linear;
path.point[1].profile.type = ProfileType::Trapezoidal;
path.point[1].profile.velocity = 1000;
path.point[1].profile.acc = 2000;
path.point[1].profile.dec = 2000;
path.point[1].target[0] = 1000;
path.point[1].target[1] = 1000;

path.point[2].type = AdvMotion::PathIntplSegmentType::Linear;
path.point[2].profile.type = ProfileType::Trapezoidal;
path.point[2].profile.velocity = 1000;
path.point[2].profile.acc = 2000;
path.point[2].profile.dec = 2000;
path.point[2].target[0] = 0;
path.point[2].target[1] = 1000;

path.point[3].type = AdvMotion::PathIntplSegmentType::Linear;
path.point[3].profile.type = ProfileType::Trapezoidal;
path.point[3].profile.velocity = 1000;
path.point[3].profile.acc = 2000;
path.point[3].profile.dec = 2000;
path.point[3].target[0] = 0;
path.point[3].target[1] = 0;

wmxlib_AdvancedMotion->advMotion->AddPathIntplWithRotationCommand(0, &path);

//Execute path interpolation with rotation
wmxlib_AdvancedMotion->advMotion->StartPathIntplWithRotation(0);

//Wait until the path interpolation with rotation is in Idle state
AdvMotion::PathIntplWithRotationStatus pathStatus;
wmxlib_AdvancedMotion->advMotion->GetPathIntplWithRotationStatus(0, &pathStatus);
while(pathStatus.state != AdvMotion::PathIntplWithRotationState::Idle) {
    Sleep(10);
    wmxlib_AdvancedMotion->advMotion->GetPathIntplWithRotationStatus(0, &pathStatus);
}

//Free the path interpolation with rotation buffer (normally, the buffer should only be freed at the end of the application)
wmxlib_AdvancedMotion->advMotion->FreePathIntplWithRotationBuffer(0);

The following plots show the two-dimensional trajectory of the X and Y axes, the positions of the X, Y, and rotational axes vs. time, and the velocities of the X, Y, and rotational axes vs. time.

../_images/WMXDOC_FUNC_PTR_image3.png

In this default configuration (except for disabling rotating the X and Y axes around the center of rotation), the sequence is executed as follows.

  1. The X and Y axes move along the first linear segment.

  2. The rotational axis rotates to point in the direction of the second linear segment.

  3. The X and Y axes move along the second linear segment.

  4. The rotational axis rotates to point in the direction of the third linear segment.

  5. The X and Y axes move along the third linear segment.

  6. The rotational axis rotates to point in the direction of the fourth linear segment.

  7. The X and Y axes move along the fourth linear segment.