using RSI.RapidCode.dotNET;
using NUnit.Framework;
using System;
#if DOXYGEN
#endif
[TestFixture]
[Category("Software")]
class MultiAxisMotion : StaticMemoryTestBase
{
[Test]
public void MultiAxisVelocityMotion()
{
const int cycles = 2;
const int NUM_OF_AXES = 6;
int i;
double[] accelerations = new double[6] { 1000, 1000, 1000, 1000, 1000, 1000 };
double[] velocities = new double[6];
Random rnd = new Random();
Axis x_axis = controller.
AxisGet(Constants.X_AXIS_NUMBER);
Axis y_axis = controller.
AxisGet(Constants.Y_AXIS_NUMBER);
Axis z_axis = controller.
AxisGet(Constants.Z_AXIS_NUMBER);
Axis a_axis = controller.
AxisGet(Constants.A_AXIS_NUMBER);
Axis b_axis = controller.
AxisGet(Constants.B_AXIS_NUMBER);
Axis c_axis = controller.
AxisGet(Constants.C_AXIS_NUMBER);
for (i = 0; i < cycles; i++)
{
int random_vel1 = rnd.Next(1, 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,
random_vel2,
random_vel3,
random_vel4,
random_vel5,
random_vel6 };
System.Threading.Thread.Sleep(100);
}
}
[Test]
public void PointToPointMultiAxisMotion()
{
const int NUM_OF_AXES = 2;
double[] positions1 = new double[NUM_OF_AXES] { 5, 10 };
double[] positions2 = new double[NUM_OF_AXES] { 15, 15 };
double[] velocities1 = new double[NUM_OF_AXES] { 1000, 1000 };
double[] velocities2 = new double[NUM_OF_AXES] { 1000, 1000 };
double[] accelerations = new double[NUM_OF_AXES] { 500, 500 };
double[] decelerations = new double[NUM_OF_AXES] { 500, 500 };
double[] jerkPercent = new double[NUM_OF_AXES] { 50, 50 };
Axis axis0 = controller.
AxisGet(Constants.X_AXIS_NUMBER);
Axis axis1 = controller.
AxisGet(Constants.Y_AXIS_NUMBER);
multi.
MoveSCurve(positions1, velocities1, accelerations, decelerations, jerkPercent);
Assert.That(axis0.
CommandPositionGet(), Is.EqualTo(positions1[0]),
"The first axis in the multi axis object should be commanded to move to the firt element of the array");
Assert.That(axis1.
CommandPositionGet(), Is.EqualTo(positions1[1]),
"The second axis in the multi axis object should be commanded to move to the second element of the array");
multi.
MoveTrapezoidal(positions2, velocities2, accelerations, decelerations);
Assert.That(axis0.
CommandPositionGet(), Is.EqualTo(positions2[0]),
"The first axis in the multi axis object should be commanded to move to the firt element of the array");
Assert.That(axis1.
CommandPositionGet(), Is.EqualTo(positions2[1]),
"The second axis in the multi axis object should be commanded to move to the second element of the array");
}
}
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCodeObject has any errors.
Helper Functions for checking logged creation errors, starting the network, etc.
double CommandPositionGet()
Get the current command position.
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,...
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.
MultiAxis * MultiAxisGet(int32_t motionSupervisorNumber)
MultiAxisGet returns a pointer to a MultiAxis object and initializes its internals.
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the controller.
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 MoveVelocity(const double *const velocity, const double *const accel)
Velocity 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...
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void AmpEnableSet(bool enable)
Enable all amplifiers.
void Abort()
Abort an axis.
int32_t MotionDoneWait()
Waits for a move to complete.
RSIAction
Action to perform on an Axis.