using System.Threading;
Console.WriteLine("📜 Axis Motion: Point to Point");
int exitCode = 0;
const double POSITION = 10;
const double VELOCITY = 10;
const double ACCELERATION = 20;
const double DECELERATION = 20;
const double JERK_PERCENT = 50;
const double FINAL_VELOCITY = 5;
try
{
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller);
Console.WriteLine("\n1. Absolute Motion");
Console.WriteLine($" CommandPosition after absolute motion: {axis.CommandPositionGet()} (expected: {POSITION})");
Console.WriteLine("\n2. S-Curve Motion");
axis.
MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
Console.WriteLine($" CommandPosition after s-curve motion: {axis.CommandPositionGet()} (expected: {POSITION})");
Console.WriteLine("\n3. Relative Motion");
axis.
MoveRelative(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
axis.
MoveRelative(-POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
Console.WriteLine($" CommandPosition after relative motion: {axis.CommandPositionGet()} (expected: 0)");
Console.WriteLine("\n4. Final Velocity Motion");
axis.
MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT, FINAL_VELOCITY);
Thread.Sleep(100);
Console.WriteLine($" CommandVelocity after final velocity motion: {axis.CommandVelocityGet()} (expected: {FINAL_VELOCITY})");
Console.WriteLine("\n5. Velocity Motion");
Thread.Sleep(100);
Console.WriteLine($" CommandVelocity after velocity motion: {axis.CommandVelocityGet()} (expected: {VELOCITY}) ");
}
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.
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 PositionSet(double position)
Set the Command and Actual positions.
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,...
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...
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void Abort()
Abort an axis.
bool StatusBitGet(RSIEventType bitMask)
Return the state of a status bit.
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.
RSIEventType
Event Types or Status Bits.
Helpers namespace provides utility functions for common tasks in RMP applications.