APIs, concepts, guides, and more
axis-motion-point-to-point.cs
Note
See Motion: Point-to-Point 📜 for a detailed explanation of this sample code.
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.
/* This sample demonstrates various point-to-point motion commands for single axis motion.
Shows trapezoidal, S-curve, relative, final velocity, and velocity motion profiles.
Each motion command is followed by MotionDoneWait() to ensure completion before proceeding.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
using System.Threading;
Console.WriteLine("📜 Axis Motion: Point to Point");
// set sample config params
const double POSITION = 10;
const double VELOCITY = 10;
const double ACCELERATION = 100;
const double DECELERATION = 100;
const double JERK_PERCENT = 50;
const double FINAL_VELOCITY = 5;
// get rmp objects
try
{
Helpers.CheckErrors(controller);
// get axis
Axis axis = controller.AxisGet(Constants.AXIS_0_INDEX);
Helpers.CheckErrors(axis);
// configure phantom axis
Helpers.PhantomAxisReset(axis);
/*
┌──────────┐
│ ABSOLUTE │
└──────────┘
*/
Console.WriteLine("\n1. Absolute Motion");
axis.AmpEnableSet(true);
axis.MoveTrapezoidal(POSITION, VELOCITY, ACCELERATION, DECELERATION);
axis.MotionDoneWait(); // wait for motion to complete
Console.WriteLine($" CommandPosition after absolute motion: {axis.CommandPositionGet()} (expected: {POSITION})");
Helpers.PhantomAxisReset(axis); // reset
/*
┌─────────┐
│ S-CURVE │
└─────────┘
*/
Console.WriteLine("\n2. S-Curve Motion");
axis.AmpEnableSet(true);
axis.MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
axis.MotionDoneWait(); // wait for motion to complete
Console.WriteLine($" CommandPosition after s-curve motion: {axis.CommandPositionGet()} (expected: {POSITION})");
Helpers.PhantomAxisReset(axis); // reset
/*
┌──────────┐
│ RELATIVE │
└──────────┘
*/
Console.WriteLine("\n3. Relative Motion");
axis.AmpEnableSet(true);
axis.MoveRelative(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
axis.MotionDoneWait(); // wait for motion to complete
// move back to start using negative relative motion
axis.MoveRelative(-POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
axis.MotionDoneWait(); // wait for motion to complete
Console.WriteLine($" CommandPosition after relative motion: {axis.CommandPositionGet()} (expected: 0)");
Helpers.PhantomAxisReset(axis); // reset
/*
┌────────────────┐
│ FINAL VELOCITY │
└────────────────┘
*/
Console.WriteLine("\n4. Final Velocity Motion");
axis.AmpEnableSet(true);
axis.MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT, FINAL_VELOCITY); // axis continues at final velocity after reaching position
// wait until axis transitions to final velocity
while (axis.StatusBitGet(RSIEventType.RSIEventTypeMOTION_AT_VELOCITY) == false)
Thread.Sleep(100);
Console.WriteLine($" CommandVelocity after final velocity motion: {axis.CommandVelocityGet()} (expected: {FINAL_VELOCITY})");
Helpers.PhantomAxisReset(axis); // reset
/*
┌──────────┐
│ VELOCITY │
└──────────┘
*/
Console.WriteLine("\n5. Velocity Motion");
axis.AmpEnableSet(true);
axis.MoveVelocity(VELOCITY, ACCELERATION); // move at constant velocity
// wait until axis reaches target position, then stop
while (axis.CommandPositionGet() < POSITION)
Thread.Sleep(100);
Console.WriteLine($" CommandVelocity after velocity motion: {axis.CommandVelocityGet()} (expected: {VELOCITY}) ");
Helpers.PhantomAxisReset(axis); // reset
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
Constants used in the C# sample apps.
Definition _constants.cs:3
const int AXIS_0_INDEX
Default: 0.
Definition _constants.cs:11
double CommandPositionGet()
Get the current command position.
void MoveVelocity(double velocity)
void MoveTrapezoidal(double position, double vel, double accel, double decel)
Point-to-point trapezoidal move.
void MoveRelative(double relativePosition, double vel, double accel, double decel, double jerkPct)
Command a relative point-to-point S-Curve motion.
void MoveSCurve(double position, double vel, double accel, double decel, double jerkPct)
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5863
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
int32_t MotionDoneWait()
Waits for a move to complete.
bool StatusBitGet(RSIEventType bitMask)
Return the state of a status bit.
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
RSIEventType
Event Types or Status Bits.
Definition rsienums.h:966
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21