APIs, concepts, guides, and more
axis-motion-streaming-pt-whilestopping.cs
Note
See Motion: Streaming 📜 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.
/* Demonstrates how to handle PT streaming motion when stopping.
Shows the difference between Stop/Resume to continue appending points,
versus starting fresh motion after stopping.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis Streaming Motion: PT While Stopping");
// 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);
const int points = 3; // points per streaming motion call
const int emptyCount = 2; // e-stop generated if there are this number or fewer frames loaded
double[] first = [0.1, 0.2, 0.3]; // positions for first MovePT call
double[] second = [0.4, 0.5, 0.6]; // positions for second MovePT call
double[] third = [0.7, 0.8, 0.9]; // positions for third MovePT call
double[] time1 = [0.3, 0.3, 0.3]; // time deltas for first MovePT call
double[] time2 = [0.2, 0.2, 0.2]; // time deltas for second MovePT call
double[] time3 = [0.25, 0.25, 0.25]; // time deltas for third MovePT call
axis.AmpEnableSet(true);
axis.MovePT(RSIMotionType.RSIMotionTypePT, first, time1, points, emptyCount, false, false); // start motion and stream points
axis.MovePT(RSIMotionType.RSIMotionTypePT, second, time2, points, emptyCount, false, false); // append points
// after Stop() on streaming motion, you can:
// 1. Resume() to continue appending points to existing motion
// 2. Discard previous points and start new motion
axis.Stop(); // puts axis in STOPPED state
// axis.EStop(); // puts axis in ERROR state (must ClearFaults() before continuing)
// axis.Abort(); // puts axis in ERROR state and triggers AmpEnable(false) (must call AmpEnable(true) before continuing)
axis.MotionDoneWait(); // wait for axis to stop
axis.Resume(); // resume appends next points to existing motion, without Resume(), new points start fresh motion
// append or start new based on Resume() call
axis.MovePT(RSIMotionType.RSIMotionTypePT, third, time3, points, emptyCount, false, true);
// wait for motion to complete
Console.WriteLine($"Final position: {axis.CommandPositionGet()}");
// cleanup
Helpers.AbortMotionObject(axis);
}
// 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
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.
void Resume()
Resume an axis.
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
void MovePT(RSIMotionType type, const double *const position, const double *const time, int32_t pointCount, int32_t emptyCount, bool retain, bool final)
A move commanded by a list of position and time points.
RSIMotionType
PT and PVT streaming motion types.
Definition rsienums.h:1038
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21