Additive linear move
The way Additive moves an axis group is "distance." Just like Relative, you decide how far your group moves. The difference is that Additive adds a distance after the group reaches a position or travels a distance commanded by the previous function. Additive can be used independently or with Absolute or Relative.
Functions
MoveLinearAdditive: moves an axis group a specified distance from the last commanded position.
GetAGroupPosition: gets and displays the set and actual positions of a group. For further details, see Get and set group values.
MoveLinearAdditive
MoveLinearAdditive moves an axis group from the last commanded position. The axis group stops after it travels the specified distance.
Starting point: this is where your group starts traveling. It is zero.
Relative distance: the relative distance your group travels. It is 10000.
Absolute position: the target position your group will reach. It is 10000. This is where MoveLinearAdditive starts to move.
Additive distance: the additional distance the group will travel after it reaches a position or travels a distance commanded by the previous motion command. It is 4000.
Notice the following parameters:
- Length: the length of the Distance array.
- Distance: the distance for each axis in the group to travel. It is an array.
- BufferMode: defines how to blend the velocity of two functions. See the McBufferMode type. For details, see Chapter 5: Single-Axis Motion > Motion states -> Common parameters.
- TransitionMode: inserts a transition curve to blend the path. If you want to perform a sequence of movements smoothly, you need to use this parameter. In KS 4.2, KINGSTAR supports only
mcCornerDistance
. See the McTransitionMode type.
BufferMode and TransitionMode are relevant to blending. For more information about blending, see Blend movements.
Code
When you make a linear move, you can choose to use blending or not. We demonstrate this function without blending. For more information about a blending sample, see Blending for group motion.
In GroupMotion.cpp
, add the following code:
MoveLinearAdditive
VOID MoveLinearAdditiveGroup(int Group)
{
RtPrintf("Make linear additive group move.\n\n");
const int LENGTH = 3; //The length of the Distance array.
double Distance[LENGTH] = { -3000, -2000, -4000 };
KsCommandStatus additiveMove = WaitForCommand(30, TRUE, MoveLinearAdditive(Group, LENGTH,
Distance, MAXIMUM_VELOCITY, MAXIMUM_ACCELERATION, MAXIMUM_DECELERATION, MAXIMUM_JERK,
mcAxisCoordSystem, mcAborting, mcNone, NULL));
if (additiveMove.Error)
RtPrintf("MoveLinearAdditive failed: %d\n\n", additiveMove.ErrorId);
//Wait a few cycles to get the correct end positions.
Sleep(5);
//Display the end positions.
RtPrintf("End positions:\n\n");
GetAGroupPosition(Group);
}
Output:
Relative distance: 5000, 6000, 7000
Additive distance: -3000, -2000, -4000