APIs, concepts, guides, and more
Motion: Streaming

Learn how to use streaming motion in C#.

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:


📜 Streaming Motion: PT

Learn how to use PT Streaming Motion 📖 motion with position and time arrays. PT motion is the simplest streaming motion requiring only position and time deltas. The controller calculates velocity and acceleration for each segment.

/* Demonstrates PT (Position-Time) streaming motion.
PT motion is the simplest streaming motion requiring only position and time arrays.
The controller calculates velocity and acceleration for each segment.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis Streaming Motion: PT");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
Axis axis = controller.AxisGet(Constants.AXIS_0_INDEX);
Helpers.CheckErrors(axis);
// configure phantom axis
Helpers.PhantomAxisReset(axis);
int points = 3; // total number of streamed points
int emptyCount = 2; // e-stop generated if there are this number or fewer frames loaded
double[] positions = [1.0, 0.5, 0.75]; // positions to reach
double[] times = [0.2, 0.3, 0.1]; // time deltas for each position (velocity and acceleration calculated by RMP)
axis.AmpEnableSet(true);
axis.MovePT(RSIMotionType.RSIMotionTypePT, // type of PT motion (RSIMotionTypePT, RSIMotionTypeBSPLINE, RSIMotionTypeBSPLINE2)
positions, // positions to reach
times, // time deltas
points, // total number of points
emptyCount, // minimum frames before e-stop
false, // whether points are kept
true); // if this is the last MovePT call (true = final point, false = more points expected)
axis.MotionDoneWait(); // 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.
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


📜 Streaming Motion: PVT

Learn how to use PVT Streaming Motion 📖 motion with position, velocity, and time arrays. PVT motion requires specifying positions, velocities, and time deltas. The controller calculates acceleration for each segment.

/* Demonstrates PVT (Position-Velocity-Time) streaming motion.
PVT motion requires position, velocity, and time arrays.
The controller calculates acceleration for each segment.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis Streaming Motion: PVT");
// 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);
int points = 3; // total number of streamed points
int emptyCount = 2; // e-stop generated if there are this number or fewer frames loaded
double[] positions = [1.0, 0.5, 0.75]; // positions to reach
double[] velocities = [12.0, 10.0, 6.0]; // velocities for each position
double[] times = [0.1, 0.2, 0.1]; // time deltas (acceleration calculated by RMP)
axis.AmpEnableSet(true);
axis.MovePVT(positions, // positions to reach
velocities, // velocities for each position
times, // time deltas
points, // total number of points
emptyCount, // minimum frames before e-stop
false, // whether points are kept
true); // if this is the last MovePVT call (true = final point, false = more points expected)
axis.MotionDoneWait(); // wait for motion to complete
Console.WriteLine($"Final position: {axis.CommandPositionGet()}");
// cleanup
Helpers.AbortMotionObject(axis);
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
void MovePVT(const double *const position, const double *const velocity, const double *const time, int32_t pointCount, int32_t emptyCount, bool retain, bool final)
Move commanded by list of positions, velocities, and times.


📜 Streaming Motion: PVAJT

Learn how to use PVAJT Streaming Motion 📖 motion with position, velocity, acceleration, jerk, and time arrays. PVAJT motion provides complete control over all motion parameters for each segment.

/* Demonstrates PVAJT (Position-Velocity-Acceleration-Jerk-Time) streaming motion.
PVAJT motion requires position, velocity, acceleration, jerk, and time arrays.
The controller uses all specified motion parameters for each segment.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Axis Streaming Motion: PVAJT");
// 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);
int points = 3; // total number of streamed points
int emptyCount = 2; // e-stop generated if there are this number or fewer frames loaded
double[] positions = [1.0, 0.5, 0.75]; // positions to reach
double[] velocities = [10.0, 20.0, 40.0]; // velocities for each position
double[] accelerations = [4, 4, 4]; // accelerations for each move
double[] jerks = [50, 50, 50]; // jerks for each move
double[] times = [0.4, 0.2, 0.1]; // time deltas for each position
axis.AmpEnableSet(true);
axis.MovePVAJT(positions, // positions to reach
velocities, // velocities for each position
accelerations, // accelerations for each move
jerks, // jerks for each move
times, // time deltas
points, // total number of points
emptyCount, // minimum frames before e-stop
false, // whether points are kept
true); // if this is the last MovePVAJT call (true = final point, false = more points expected)
// wait for motion to complete
Console.WriteLine($"Final position: {axis.CommandPositionGet()}");
// cleanup
Helpers.AbortMotionObject(axis);
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
void MovePVAJT(const double *const position, const double *const velocity, const double *const acceleration, const double *const jerk, const double *const time, int32_t pointCount, int32_t emptyCount, bool retain, bool final)


📜 Streaming Motion: PT While Stopping

Learn how to handle stopping and resuming PT Streaming Motion 📖 motion. Demonstrates the difference between Resume() to continue appending points versus starting fresh motion.

/* 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
}
void Resume()
Resume an axis.