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.
Console.WriteLine("📜 Axis Streaming Motion: PT");
int exitCode = 0;
try
{
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller);
int points = 3;
int emptyCount = 2;
double[] positions = [1.0, 0.5, 0.75];
double[] times = [1, 0.5, 2];
positions,
times,
points,
emptyCount,
false,
true);
Console.WriteLine($"Final position: {axis.CommandPositionGet()}");
}
catch (Exception e)
{
Console.WriteLine($"❌ Error: {e.Message}");
}
finally
{
controller.Delete();
}
return exitCode;
Constants used in the C# sample apps.
const bool USE_HARDWARE
Default: false.
const int EXIT_FAILURE
Exit code for failed execution.
const int AXIS_0_INDEX
Default: 0.
const int AMP_ENABLE_MS
Default: 750.
const int EXIT_SUCCESS
Exit code for successful execution.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
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...
int32_t MotionDoneWait(int32_t waitTimeoutMilliseconds=WaitForever)
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.
Helpers namespace provides utility functions for common tasks in RMP applications.
📜 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.
Console.WriteLine("📜 Axis Streaming Motion: PVT");
int exitCode = 0;
try
{
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller);
int points = 3;
int emptyCount = 2;
double[] positions = [1.0, 0.5, 0.75];
double[] velocities = [12.0, 10.0, 6.0];
double[] times = [0.1, 0.2, 0.1];
velocities,
times,
points,
emptyCount,
false,
true);
Console.WriteLine($"Final position: {axis.CommandPositionGet()}");
}
catch (Exception e)
{
Console.WriteLine($"❌ Error: {e.Message}");
}
finally
{
controller.Delete();
}
return exitCode;
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.
Console.WriteLine("📜 Axis Streaming Motion: PVAJT");
int exitCode = 0;
try
{
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller);
int points = 3;
int emptyCount = 2;
double[] positions = [1.0, 0.5, 0.75];
double[] velocities = [10.0, 20.0, 40.0];
double[] accelerations = [4, 4, 4];
double[] jerks = [50, 50, 50];
double[] times = [0.4, 0.2, 0.1];
velocities,
accelerations,
jerks,
times,
points,
emptyCount,
false,
true);
Console.WriteLine($"Final position: {axis.CommandPositionGet()}");
}
catch (Exception e)
{
Console.WriteLine($"❌ Error: {e.Message}");
}
finally
{
controller.Delete();
}
return exitCode;
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.
Console.WriteLine("📜 Axis Streaming Motion: PT While Stopping");
int exitCode = 0;
try
{
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller);
const int points = 3;
const int emptyCount = 2;
double[] first = [0.1, 0.2, 0.3];
double[] second = [0.4, 0.5, 0.6];
double[] third = [0.7, 0.8, 0.9];
double[] time1 = [0.3, 0.3, 0.3];
double[] time2 = [0.2, 0.2, 0.2];
double[] time3 = [0.25, 0.25, 0.25];
Console.WriteLine("Motion stopped.");
Console.WriteLine($"Final position: {axis.CommandPositionGet()}");
}
catch (Exception e)
{
Console.WriteLine($"❌ Error: {e.Message}");
}
finally
{
controller.Delete();
}
return exitCode;
void PositionSet(double position)
Set the Command and Actual positions.
void Resume()
Resume an axis.