GetAGroupVelocity

GetGroupVelocity gets the velocity of each axis in a group and path velocity of a group. Path velocity is the total amount of the velocity of the grouped axes, calculated using the following formula:

You can use GetGroupVelocity to check how fast a group moves. After we get the velocity, we use GetGroupConfiguration to detect which axes are in the group, and display each axis' velocity and the path velocity.

Notice that we use the variable LENGTH to control the length of the array, which represents how many axes in a group. If you change the number of the axes in your group, remember to change this value.

Copy

GetAGroupVelocity

VOID GetAGroupVelocity(int& Group)
{
    const int LENGTH = 3;   //Array length. It indicates how many axes in a group.
                            /*Remember to change this value when you change the number of the
                              axes in a group.*/
    int AxisIndex = 0;      //Receive the returned value from GetGroupConfiguration.
    int AxisInGroup[LENGTH] = { 0 };      /*The array that presents the indexes of the
                                            axes in a group.*/
    int OriginalIndex[LENGTH] = { 0 };    //The original indexes of the axes.
    double Velocity[LENGTH] = { 0 };      //The velocity of the axes.
    double PathVelocity = 0;              //The total amount of the velocity of the axes.
    KsError nRet = errNoError;

    //Get the velocity and path velocity of a group.
    nRet = GetGroupVelocity(Group, mcAxisCoordSystem, mcSetValue, LENGTH, Velocity, &PathVelocity);
    if (nRet != errNoError)
        RtPrintf("Unable to get the velocity: %x\n", nRet);

    //Initialize AxisInGroup using sequential numbers.
    for (int i = 0; i < LENGTH; i++)
        AxisInGroup[i] = i;

    for (int i = 0; i < LENGTH; i++)
    {
        //Check the axes in a group, and pass their original index to OriginalIndex.
        KsError nRet = GetGroupConfiguration(Group, AxisInGroup[i], mcAxisCoordSystem, &AxisIndex);
        OriginalIndex[i] = AxisIndex;
    }

    //Display the positions of the axes in a group.
    for (int i = 0; i < LENGTH; i++)
        printf("Axis %d Velocity: %f\n", OriginalIndex[i],
            Velocity[i]);

    RtPrintf("\n");
    printf("Path velocity is %f\n\n", PathVelocity);
}