#include "rsi.h"
#include "SampleAppsHelper.h"
#include <conio.h>
#include "SampleApps.h"
void PrintResult(
Axis* axisX,
Axis* axisY)
{
printf("Motion Done \n AxisX position-> Commanded: %f \tActual: %f\n",
printf(" AxisY position-> Commanded: %f \tActual: %f\n",
}
int MultiaxisMotion::Run()
{
const int AXIS_COUNT = 2;
const int AXIS_X = 0;
const int AXIS_Y = 1;
const int MOTION_COUNT = 1;
const double USER_UNITS = 1048576;
const double START_POSITION[AXIS_COUNT] = { 0, 0 };
const double END_POSITION[AXIS_COUNT] = { 1, 2 };
const double VELOCITY[AXIS_COUNT] = { 1, 2 };
const double ACCELERATION[AXIS_COUNT] = { 10, 20 };
const double DECELERATION[AXIS_COUNT] = { 10, 20 };
const double JERK_PERCENTAGE[AXIS_COUNT] = { 0, 0 };
if (USE_HARDWARE)
{
}
else
{
}
try
{
controller->MotionCountSet(controller->AxisCountGet() + 1);
Axis* axisX = controller->AxisGet(AXIS_X);
Axis* axisY = controller->AxisGet(AXIS_Y);
MultiAxis* multiAxisXY = controller->MultiAxisGet(controller->MotionCountGet() - 1);
printf("\nMotionStart...");
multiAxisXY->
MoveSCurve(END_POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENTAGE);
PrintResult(axisX, axisY);
printf("\nMotionStart...");
multiAxisXY->
MoveSCurve(START_POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENTAGE);
PrintResult(axisX, axisY);
printf("\nTrapezoidal Motion Done\n");
}
{
printf(
"\n%s\n", err.
text);
return -1;
}
controller->Delete();
return 0;
}
double CommandPositionGet()
Get the current command position.
void UserUnitsSet(double countsPerUserUnit)
Sets the number of counts per User Unit.
void ErrorLimitActionSet(RSIAction action)
Set the action that will occur when the Error Limit Event triggers.
void PositionSet(double position)
Set the Command and Actual positions.
double ActualPositionGet()
Get the current actual position.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
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...
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.
void MotionAttributeMaskOnSet(RSIMotionAttrMask maskOn)
Turn on a particular motion attribute mask.
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
@ RSIActionNONE
None - do not perform any action.
@ RSIMotionAttrMaskSYNC_START
Synchronize start of motion for all axes.
@ RSIMotionAttrMaskSYNC_END
Synchronize end of motion for all axes.
constexpr bool USE_HARDWARE
Flag for whether to use hardware or phantom axes.
static void SetupControllerForHardware(MotionController *controller)
Sets up the controller for hardware use by resetting it and starting the network.
static void CheckErrors(RapidCodeObject *rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
static void SetupControllerForPhantoms(MotionController *controller, int axisCount, std::vector< int > axisNums)
Sets up the controller for phantom axes, including configuring specified axes as phantom.