The RMP Motion Controller APIs

◆ MoveVelocity() [2/2]

void MoveVelocity ( const double *const  velocity,
const double *const  accel 
MoveVelocity commands the MultiAxis to a specified target velocity set independently for each Axis.
*velArray of target velocities (UserUnits/second).
*accelArray of accelerations (UserUnits/second/second).
This function is also available in RapidSequencer.
Sample Code:
// RapidCode Objects
MultiAxis multi; // Declare what multi is.
// Constants
const int cycles = 2; // Specify how many times you want to update the velocity.
const int NUM_OF_AXES = 6;
controller.MotionCountSet(NUM_OF_AXES + 1); // We will need a motion supervisor for every Axis object and MultiAxis object
int i;
double[] accelerations = new double[6] { 1000, 1000, 1000, 1000, 1000, 1000 }; // Specify the acceleration for all 6 axes.
double[] velocities = new double[6]; // Initialize the array that will contain the velocities of all 6 axes.
Random rnd = new Random(); // Initialize the Random object that we will use to generate random velocities.
Axis x_axis = controller.AxisGet(Constants.X_AXIS_NUMBER); // Initialize axis. (You can use RapidSetup to see what axes you are using.)
Axis y_axis = controller.AxisGet(Constants.Y_AXIS_NUMBER); // Initialize axis.
Axis z_axis = controller.AxisGet(Constants.Z_AXIS_NUMBER); // Initialize axis.
Axis a_axis = controller.AxisGet(Constants.A_AXIS_NUMBER); // Initialize axis.
Axis b_axis = controller.AxisGet(Constants.B_AXIS_NUMBER); // Initialize axis.
Axis c_axis = controller.AxisGet(Constants.C_AXIS_NUMBER); // Initialize axis.
HelperFunctions.CheckErrors(x_axis); // Check that the axis has been initialize correctly.
HelperFunctions.CheckErrors(y_axis); // Check that the axis has been initialize correctly.
HelperFunctions.CheckErrors(z_axis); // Check that the axis has been initialize correctly.
HelperFunctions.CheckErrors(a_axis); // Check that the axis has been initialize correctly.
HelperFunctions.CheckErrors(b_axis); // Check that the axis has been initialize correctly.
HelperFunctions.CheckErrors(c_axis); // Check that the axis has been initialize correctly.
multi = controller.MultiAxisGet(NUM_OF_AXES); // Configure your MultiAxis on RapidSetup (Make sure MotionCount is 1 higher than AxisCount)
HelperFunctions.CheckErrors(multi); // Check that multi has been initialized correctly.
multi.AxisRemoveAll(); // If there are any current axes on multi, remove them.
multi.AxisAdd(x_axis); // Add axis to your Multi-Axis controller.
multi.AxisAdd(y_axis); // Add axis to your Multi-Axis controller.
multi.AxisAdd(z_axis); // Add axis to your Multi-Axis controller.
multi.AxisAdd(a_axis); // Add axis to your Multi-Axis controller.
multi.AxisAdd(b_axis); // Add axis to your Multi-Axis controller.
multi.AxisAdd(c_axis); // Add axis to your Multi-Axis controller.
multi.Abort(); // If there is any motion happening, abort it.
multi.ClearFaults(); // Clear faults and enable all axes.
multi.AmpEnableSet(true); // Enable the motor.
for (i = 0; i < cycles; i++) // This loop will iterate 5 times based on the value of "cycles"
int random_vel1 = rnd.Next(1, 100); // random_vel1 is a number [ >= 1 and < 100 ]
int random_vel2 = rnd.Next(1, 100);
int random_vel3 = rnd.Next(1, 100);
int random_vel4 = rnd.Next(1, 100);
int random_vel5 = rnd.Next(1, 100);
int random_vel6 = rnd.Next(1, 100);
velocities = new double[6] {random_vel1, // Update axis's velocity.
random_vel2, // Update axis's velocity.
random_vel3, // Update axis's velocity.
random_vel4, // Update axis's velocity.
random_vel5, // Update axis's velocity.
random_vel6 }; // Update axis's velocity.
multi.MoveVelocity(velocities, accelerations); // Move your Multi-Axis. (this will also update the move on the fly)
System.Threading.Thread.Sleep(100); // Sleep for 100ms before iterating again.
multi.Abort(); // Stop motion on all axes.
See also
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the controller.
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
void MotionCountSet(int32_t motionCount)
Set the number of processed Motion Supervisors in the controller.
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCode Object has any errors.
Definition: HelperFunctions.cs:64
MultiAxis * MultiAxisGet(int32_t motionSupervisorNumber)
MultiAxisGet returns a pointer to a MultiAxis object and initializes its internals.
Helper Functions for checking logged creation errors, starting the network, etc.
Definition: HelperFunctions.cs:50