APIs, concepts, guides, and more

◆ MultiAxisGet()

MultiAxis * MultiAxisGet ( int32_t motionSupervisorNumber)
Description:
MultiAxisGet returns a pointer to a MultiAxis object and initializes its internals.
Parameters
motionSupervisorNumberA motion supervisor index, should be >= AxisCount.
Returns
(MultiAxis*) A pointer to the MultiAxis specified.
Sample Code:
Motion: Multi-Axis
/* This sample demonstrates both trapezoidal and S-curve point-to-point motion profiles for multi-axis motion.
The MultiAxis object coordinates the motion of multiple axes simultaneously.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 MultiAxis Motion: Point to Point");
// get rmp objects
MotionController controller = MotionController.Get();
try
{
Helpers.CheckErrors(controller);
// set the motion count to AxisCount + 1, every multiaxis needs a motion supervisor
var axisCount = controller.AxisCountGet();
controller.MotionCountSet(axisCount + 1);
// get axes
Axis axis0 = controller.AxisGet(Constants.AXIS_0_INDEX);
Axis axis1 = controller.AxisGet(Constants.AXIS_1_INDEX);
// get multiaxis (motion supervisor number is equal to number of axes because indexing starts at 0)
MultiAxis multi = controller.MultiAxisGet(axisCount);
// remove any existing axes
multi.AxisRemoveAll();
// add axes to multiaxis
multi.AxisAdd(axis0);
multi.AxisAdd(axis1);
// prepare for motion
multi.Abort(); // stop any existing motion
multi.ClearFaults();
multi.AmpEnableSet(true);
// disable position error for phantom axes
axis0.ErrorLimitActionSet(RSIAction.RSIActionNONE);
axis1.ErrorLimitActionSet(RSIAction.RSIActionNONE);
// define motion parameters
double[] positions1 = [ 5, 10 ]; // first set of positions
double[] positions2 = [ 15, 15 ]; // second set of positions
double[] velocities1 = [ 1000, 1000 ]; // velocities for first move
double[] velocities2 = [ 1000, 1000 ]; // velocities for second move
double[] accelerations = [ 500, 500 ]; // accelerations for both axes
double[] decelerations = [ 500, 500 ]; // decelerations for both axes
double[] jerkPercent = [ 50, 50 ]; // jerk percent for s-curve motion
// move using s-curve motion profile
Console.WriteLine($"\nMove 1 (S-Curve): Positions = [{positions1[0]}, {positions1[1]}]");
multi.MoveSCurve(positions1, velocities1, accelerations, decelerations, jerkPercent);
multi.MotionDoneWait(); // wait for motion to complete
Console.WriteLine($"Axis 0 CommandPosition: {axis0.CommandPositionGet()} (expected: {positions1[0]})");
Console.WriteLine($"Axis 1 CommandPosition: {axis1.CommandPositionGet()} (expected: {positions1[1]})");
// move using trapezoidal motion profile
Console.WriteLine($"\nMove 2 (Trapezoidal): Positions = [{positions2[0]}, {positions2[1]}]");
multi.MoveTrapezoidal(positions2, velocities2, accelerations, decelerations);
multi.MotionDoneWait(); // wait for motion to complete
Console.WriteLine($"Axis 0 CommandPosition: {axis0.CommandPositionGet()} (expected: {positions2[0]})");
Console.WriteLine($"Axis 1 CommandPosition: {axis1.CommandPositionGet()} (expected: {positions2[1]})");
// cleanup
controller.MotionCountSet(axisCount); // remove multiaxis
Console.WriteLine("\nMulti-axis point-to-point motion complete.");
}
// 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
const int AXIS_1_INDEX
Default: 1.
Definition _constants.cs:12
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
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
void ErrorLimitActionSet(RSIAction action)
Set the action that will occur when the Error Limit Event triggers.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5863
void MoveTrapezoidal(const double *const position, const double *const vel, const double *const accel, const double *const decel)
Point-to-point trapezoidal move.
void AxisRemoveAll()
Remove all axes from a MultiAxis group.s.
void MoveSCurve(const double *const position, const double *const vel, const double *const accel, const double *const decel, const double *const jerkPct)
Point-to-point S-Curve Move.
void AxisAdd(Axis *axis)
Add an Axis to a MultiAxis group.
Represents multiple axes of motion control, allows you to map two or more Axis objects together for e...
Definition rsi.h:10795
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void Abort()
Abort an axis.
int32_t MotionDoneWait()
Waits for a move to complete.
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
RSIAction
Action to perform on an Axis.
Definition rsienums.h:1115
Note
You'll need to set the number of MotionSupervisors to a number greater than the Axis count. This should be done before any calls to AxisGet or MultiAxisGet.

Creation Methods Info
Part of the Create and Initialize RapidCode Objects method group.

🔔 Important Usage Instructions
All creation methods, such as Create(), AxisGet(), NetworkNodeGet(), etc. Each return valid pointers to RapidCode objects. These pointers are never null, even when there is an error during object creation.
🔔 API Differences (C# vs. C++)
In the C# API, the pointers are replaced by references due to differences between C++ and C#. The creation methods return a reference to the object instead of a pointer. However, the method calls and error handling procedures remain the same. Null references are not returned by the creation methods in C#. Always check for errors after object creation, as described above.
⚙️ Error Checking After Creation
Immediately after the creation of a RapidCode object, you need to check if there were any errors during its creation. You do this by calling the ErrorLogCountGet() method on the created object. If ErrorLogCountGet() returns a value greater than zero, it means there were errors during the object creation.
⚙️ Handling Errors
To handle the errors, you call the ErrorLogGet() method once for each error on the created object to retrieve an RsiError object. You can then inspect the RsiError object to understand more about the error.
⚙️ Helper Functions
RapidCode also provides helper functions in both C++ and C#, like HelperFunctions::CheckErrors(), that work with all RapidCode objects. These helper functions operate on RapidCodeObject, hence they are compatible with all RapidCode objects. For example:
⚙️ Object Cleanup
Any and all objects created by RapidCode creation methods will be cleaned up by calling MotionController::Delete(). This should be done when your application is finished using RapidCode objects.
See also
ErrorLogCountGet, ErrorLogGet, Delete, HelperFunctions.CheckErrors
MultiAxis::AxisAdd , MotionCountGet , MotionCountSet