The RMP Motion Controller APIs
Motion.cs
using RSI.RapidCode.dotNET; // Import our RapidCode Library.
using NUnit.Framework;
[TestFixture]
[Category("Software")]
public class Motion : SampleAppTestBase
{
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void AbsoluteMotion()
{
axis.MoveTrapezoidal(Constants.POSITION, Constants.VELOCITY, Constants.ACCELERATION, Constants.DECELERATION);// Command simple trapezoidal motion.
axis.MotionDoneWait();// Wait for motion to be done
Assert.That(axis.CommandPositionGet(), Is.EqualTo(Constants.POSITION), "The command position should be equal to POSITION");
}
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void SCurveMotion()
{
// These duplicate axis objects are here for doxygen hyperlinking
Axis axis = controller.AxisGet(Constants.AXIS_NUMBER);
axis.MoveSCurve(Constants.POSITION); // Command SCurve Motion. This overload willuse default velocity, acceleration, deceleration, jerk values for the axis. See axis config to learn how to set those values.
axis.MotionDoneWait(); // Wait for motion to finish
Assert.That(axis.CommandPositionGet(), Is.EqualTo(Constants.POSITION), "The command position should be equal to POSITION");
}
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void FinalVelocity()
{
//These duplicate axis objects are here for doxygen hyperlinking
Axis axis = controller.AxisGet(Constants.AXIS_NUMBER);
int finalVelocity = 5;
axis.MoveSCurve(Constants.POSITION, // Command an SCurve move with a final velocity of FINAL_VELOCITY.
Constants.VELOCITY,
Constants.ACCELERATION,
Constants.DECELERATION,
Constants.JERK_PERCENT,
finalVelocity); // Once the commanded position has been reached, the motor will begin spinning with a speed of FINAL_VELOCITY, and continue to spin at that velocity until stopped.
if (axis.CommandPositionGet() >= Constants.POSITION)
{
Assert.That(axis.CommandVelocityGet(), Is.EqualTo(finalVelocity), "The command velocity should be equal to FINAL_VELOCITY");
TearDown();
}
}
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void RelativeMotion()
{
//These duplicate axis objects are here for doxygen hyperlinking
Axis axis = controller.AxisGet(Constants.AXIS_NUMBER);
axis.MoveRelative(Constants.POSITION, Constants.VELOCITY, Constants.ACCELERATION, Constants.DECELERATION, Constants.JERK_PERCENT); // Command a relative to the current position
axis.MotionDoneWait(); // Wait for motion to finish. (the motion should take 2.5 seconds)
var cmdPositionAfterMove = axis.CommandPositionGet(); // The command position should be equal to Constants.POSITION
// Move back to the start position by moving negative relative to current position
axis.MoveRelative(-1 * Constants.POSITION, Constants.VELOCITY, Constants.ACCELERATION, Constants.DECELERATION, Constants.JERK_PERCENT);
axis.MotionDoneWait();
Assert.That(cmdPositionAfterMove, Is.EqualTo(Constants.POSITION), "The command position should be equal to POSITION");
}
[Test]
public void MoveVelocity()
{
//These duplicate axis objects are here for doxygen hyperlinking
Axis axis = controller.AxisGet(Constants.AXIS_NUMBER);
axis.MoveVelocity(Constants.VELOCITY, Constants.ACCELERATION);
if (axis.CommandPositionGet() >= Constants.POSITION)
{
Assert.That(axis.CommandVelocityGet(), Is.EqualTo(Constants.VELOCITY), "The command velocity should be equal to FINAL_VELOCITY");
TearDown();
}
}
}
RSI::RapidCode
RSI
HelperFunctions.CheckErrors
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCode Object has any errors.
Definition: HelperFunctions.cs:64
HelperFunctions
Helper Functions for checking logged creation errors, starting the network, etc.
Definition: HelperFunctions.cs:50