APIs, concepts, guides, and more
axis-motion-streaming-pt-whilestopping.cs
/* 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);
// configure phantom 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
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
static void AbortMotionObject(RapidCodeMotion motionObject)
Aborts motion on the given RapidCodeMotion object (Axis or MultiAxis), waits for motion to stop,...
Definition _helpers.cs:186
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
static void PhantomAxisReset(Axis phantomAxis)
Configures a phantom axis on the controller.
Definition _helpers.cs:144
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5862
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
static MotionController * Get()
Get an already running RMP EtherCAT controller.
void Delete(void)
Delete the MotionController and all its objects.
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