APIs, concepts, guides, and more
Relative Motion

Use Relative Motion to move an axis a specified distance from its current position, providing flexibility to adjust position based on current location rather than a fixed point.

🔹 What is Relative Motion?

A Relative Motion is a motion that allows you to move to a specified distance from the current position.

🔹 Why use Relative Motion?

Relative motion allows you to move an axis a specified distance from its current position. This differs from an absolute motion in that a call to MoveSCurve(10) (an absolute move) will move the axis to position 10, while a call to MoveRelative(10) will move the axis to a position 10 units greater than the current position. For more information on Absolute Motion, visit our Absolute Motion topic page.

Example 1

A RELATIVE MOVE will move the axis 25 units ahead of the current position, rather than to position 25.

An ABSOLUTE MOVE will move the axis to position 25 rather than 25 units ahead of the current position.

Note
Relative motion always executes a SCurve motion profile. For more information on SCurve motion, visit our SCurve Motion topic page

📜 Sample Code

  • C#

    public const double POSITION = 2; // Specify the position to travel to.
    public const double VELOCITY = 200; // Specify your velocity. - units: UserUnits/Sec
    public const double ACCELERATION = 100; // Specify your acceleration. - units: UserUnits/Sec^2
    public const double DECELERATION = 100; // Specify your deceleration. - units: UserUnits/Sec^2
    public const double JERK_PERCENT = 50; // Specify your jerk percent (0.0 to 100.0)
    axis.MoveRelative(Constants.POSITION, Constants.VELOCITY, Constants.ACCELERATION, Constants.DECELERATION, Constants.JERK_PERCENT); // Command a relative to the current position
    axis.MotionDoneWait(); // Wait for motion to finish. (the motion should take 2.5 seconds)
    var cmdPositionAfterMove = axis.CommandPositionGet(); // The command position should be equal to Constants.POSITION
    // Move back to the start position by moving negative relative to current position
    axis.MoveRelative(-1 * Constants.POSITION, Constants.VELOCITY, Constants.ACCELERATION, Constants.DECELERATION, Constants.JERK_PERCENT);

  • C++

    // *NOTICE* The following constants must be configured before attempting to run with hardware.
    const int NUM_AXES = 1; // The number of axes to configure
    const int AXIS_INDEX = 0; // The index of the axis to configure
    // Motion Parameters
    const double POSITION_0 = 0;
    const double POSITION_1 = 0.5;
    const double VELOCITY = 1;
    const double ACCELERATION = 10;
    const double DECELERATION = 10;
    const double JERK_PERCENT = 50;
    const double FINAL_VELOCITY = 0.5;
    std::cout << "Relative Motion:" << std::endl;
    std::cout << "Moving to position: " << POSITION_1 << std::endl;
    axis->MoveRelative(POSITION_1 - POSITION_0, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
    axis->MotionDoneWait(TIMEOUT);
    std::cout << "Motion Complete" << std::endl;
    std::cout << "Moving back to position: " << POSITION_0 << std::endl;
    axis->MoveRelative(POSITION_0 - POSITION_1, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
    axis->MotionDoneWait(TIMEOUT);
    std::cout << "Motion Complete\n" << std::endl;