Learn how to perform various types of motion.
- Warning
- This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.
The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.
In this page:
📜 Motion: Point-to-Point
Learn how to perform point-to-point motion including absolute moves, relative moves, S-curve motion, and velocity motion with Final Velocity Motion 📖 .
const int NUM_AXES = 1;
const int AXIS_INDEX = 0;
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;
Source: point-to-point.cpp
📜 Absolute Motion
Demonstrates how to perform absolute trapezoidal motion moves.
std::cout << "Absolute (Trapezoidal) Motion:" << std::endl;
std::cout << "Moving to position: " << POSITION_1 << std::endl;
std::cout << "Motion Complete" << std::endl;
std::cout << "Moving back to position: " << POSITION_0 << std::endl;
std::cout << "Motion Complete\n" << std::endl;
📜 Relative Motion
Demonstrates how to perform relative motion moves with S-curve profiles.
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);
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);
std::cout << "Motion Complete\n" << std::endl;
📜 S-Curve Motion
Demonstrates how to perform S-curve motion using default motion parameters.
std::cout << "SCurve Motion:" << std::endl;
std::cout << "Moving to position: " << POSITION_1 << std::endl;
std::cout << "Motion Complete" << std::endl;
std::cout << "Moving back to position: " << POSITION_0 << std::endl;
std::cout << "Motion Complete\n" << std::endl;
📜 S-Curve Motion with Final Velocity
Demonstrates how to perform S-curve motion with a specified final velocity.
std::cout << "SCurve Motion with Final Velocity:" << std::endl;
std::cout << "Moving to position: " << POSITION_1 << std::endl;
std::cout << "Final Velocity: " << FINAL_VELOCITY << std::endl;
axis->
MoveSCurve(POSITION_1, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT, FINAL_VELOCITY);
HelperAtVelocityWait(controller, axis, TIMEOUT);
std::cout << "Motion Complete" << std::endl;
std::cout << "Moving back to position: " << POSITION_0 << std::endl;
std::cout << "Final Velocity: " << 0 << std::endl;
axis->
MoveSCurve(POSITION_0, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT, 0);
std::cout << "Motion Complete\n" << std::endl;
📜 Velocity Move
Demonstrates how to perform velocity moves to accelerate and decelerate to target velocities.
std::cout << "Velocity Move:" << std::endl;
std::cout << "Accelerating to velocity: " << VELOCITY << std::endl;
HelperAtVelocityWait(controller, axis, TIMEOUT);
std::cout << "Motion Complete" << std::endl;
std::cout << "Decelerating to velocity: " << 0 << std::endl;
HelperAtVelocityWait(controller, axis, TIMEOUT);
std::cout << "Motion Complete" << std::endl;