APIs, concepts, guides, and more

◆ MotionHoldAxisPositionSet()

void MotionHoldAxisPositionSet ( double position)
Description:
MotionHoldAxisPositionSet sets the position of the Axis which has a Hold.
Parameters
positionPosition to set Hold Axis to.

Part of the Motion Configuration method group.

Sample Code:
Motion: Hold
/* This sample demonstrates how to hold motion based on another axis reaching a specified position.
Uses one axis to control when another axis's motion is released, useful for synchronized operations.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Motion Hold: via Position");
int exitCode = 0;
// set sample config params
const double TRIGGER_POSITION = 1;
const int MOVING_AXIS_TARGET = 10;
const int HOLDING_AXIS_TARGET = 2;
// get rmp objects
try
{
Helpers.CheckErrors(controller);
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller, minRequiredSampleAxisCount: 2);
// get axes
Axis holdingAxis = controller.AxisGet(Constants.AXIS_0_INDEX);
Helpers.CheckErrors(holdingAxis);
Axis movingAxis = controller.AxisGet(Constants.AXIS_1_INDEX);
Helpers.CheckErrors(movingAxis);
// configure phantom axes
Helpers.PhantomAxisReset(holdingAxis);
Helpers.PhantomAxisReset(movingAxis);
holdingAxis.AmpEnableSet(true, Constants.AMP_ENABLE_MS);
// configure motion hold - holdingAxis will be held until movingAxis reaches trigger position
bool movingAxisIsHardware = movingAxis.MotorTypeGet() != RSIMotorType.RSIMotorTypePHANTOM;
RSIMotionHoldType motionHoldType = movingAxisIsHardware ?
RSIMotionHoldType.RSIMotionHoldTypeAXIS_ACTUAL_POSITION : // AXIS_ACTUAL_POSITION for hardware axes
RSIMotionHoldType.RSIMotionHoldTypeAXIS_COMMAND_POSITION; // AXIS_COMMAND_POSITION for phantom axes
holdingAxis.MotionHoldTypeSet(motionHoldType);
holdingAxis.MotionHoldAxisNumberSet(movingAxis.NumberGet()); // specify which axis position to monitor
holdingAxis.MotionHoldAxisPositionSet(TRIGGER_POSITION); // position that will release the hold
holdingAxis.MotionHoldAxisLogicSet(RSIUserLimitLogic.RSIUserLimitLogicGE); // release when position >= trigger position
// enable motion hold and command motion
holdingAxis.MotionAttributeMaskOnSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD);
holdingAxis.MoveRelative(HOLDING_AXIS_TARGET); // this motion will be held
Console.WriteLine($"\tHolding axis commanded to move to {HOLDING_AXIS_TARGET}, but motion is held");
// move the trigger axis to release the hold
movingAxis.MoveRelative(MOVING_AXIS_TARGET);
Console.WriteLine($"\tMoving axis to {MOVING_AXIS_TARGET} to release hold...");
movingAxis.MotionDoneWait();
holdingAxis.MotionDoneWait();
Console.WriteLine($"\tHolding axis final position: {holdingAxis.CommandPositionGet()} (expected: {HOLDING_AXIS_TARGET})");
Console.WriteLine($"\tMoving axis final position: {movingAxis.CommandPositionGet()} (expected: {MOVING_AXIS_TARGET})");
// cleanup
Helpers.AbortMotionObject(holdingAxis);
Helpers.AbortMotionObject(movingAxis);
exitCode = Constants.EXIT_SUCCESS;
}
// handle errors as needed
catch (Exception e)
{
Console.WriteLine($"❌ Error: {e.Message}");
exitCode = Constants.EXIT_FAILURE;
}
finally
{
controller.Delete(); // dispose
}
return exitCode;
Constants used in the C# sample apps.
Definition _constants.cs:3
const int EXIT_FAILURE
Exit code for failed execution.
Definition _constants.cs:69
const int AXIS_0_INDEX
Default: 0.
Definition _constants.cs:20
const int AMP_ENABLE_MS
Default: 750.
Definition _constants.cs:35
const int EXIT_SUCCESS
Exit code for successful execution.
Definition _constants.cs:68
const int AXIS_1_INDEX
Default: 1.
Definition _constants.cs:21
RSIMotorType MotorTypeGet()
Get the motor type.
void MoveRelative(double relativePosition, double vel, double accel, double decel, double jerkPct)
Command a relative point-to-point S-Curve motion.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5966
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
void MotionHoldAxisPositionSet(double position)
Sets the Axis position.
void MotionHoldTypeSet(RSIMotionHoldType type)
Set the motion hold type.
void MotionHoldAxisNumberSet(int32_t number)
Sets the Axis number for Motion Hold.
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.
int32_t NumberGet()
Get the axis number.
void MotionAttributeMaskOnSet(RSIMotionAttrMask maskOn)
Turn on a particular motion attribute mask.
void MotionHoldAxisLogicSet(RSIUserLimitLogic logic)
Set the logic when holding for Axis ActualPosition.
RSIUserLimitLogic
Logic options for User Limits.
Definition rsienums.h:651
RSIMotorType
Motor Type.
Definition rsienums.h:1318
RSIMotionAttrMask
Attribute masks for motion. You cannot mix RSIMotionAttrMaskDELAY and RSIMotionAttrMaskAPPEND.
Definition rsienums.h:1067
RSIMotionHoldType
Types for MotionHold attribute.
Definition rsienums.h:1102
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21
See also
MotionHoldAxisPositionGet()
Examples
axis-motion-hold-via-position.cs.