28#include "SampleApps.h"
29#include "SampleAppsHelper.h"
34int UpdateBufferPoints::Run()
40 const int AXIS_COUNT = 1;
41 const int AXIS_NUMBER = 0;
43 const double USER_UNITS = 1048576;
46 const double TIME_SLICE = 0.001;
49 const int TOTAL_POINTS = (int)(REVS / TIME_SLICE / RPS);
50 const int BUFFER_SZ = 100;
51 const int EMPTY_CT = 10;
96 std::vector<double> positions, times;
97 for (
int i = 0; i < TOTAL_POINTS; i += AXIS_COUNT)
99 positions.push_back(i * TIME_SLICE * RPS);
100 times.push_back(TIME_SLICE);
114 int curMotionElementID = 0, curMotionID = 0, finalMotionID = 0;
115 int numPointsToSend = BUFFER_SZ;
116 int endOfLastSent = 0;
117 bool exitCondition =
false;
120 const int motionHoldGate = 3;
124 for (
int i = 0; i < 2; ++i)
127 endOfLastSent += numPointsToSend;
138 while (!exitCondition)
153 if (std::abs(finalMotionID - curMotionID) < 2)
156 if (TOTAL_POINTS <= (endOfLastSent + BUFFER_SZ))
158 numPointsToSend = TOTAL_POINTS - endOfLastSent;
159 exitCondition =
true;
163 printf(
"MotionID %d\nEnd of Last Sent %d\nElement ID %d\nNum to Send %d\nIs Done %s\n===========================================\n\n",
164 curMotionID, endOfLastSent, curMotionElementID, numPointsToSend, exitCondition ?
"yes" :
"no");
166 endOfLastSent += numPointsToSend;
170 printf(
"Updates Done. Waiting to finish motion.\n");
177 printf(
"\n%s\n", err.text);
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.
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.
void SyncInterruptEnableSet(bool enable)
Configure Sync (periodic) interrupts for the controller.
void SyncInterruptPeriodSet(uint32_t samples)
Configure the period for the Sync Interrupt on the controller.
void MotionHoldGateSet(int32_t gateNumber, bool hold)
Set the Motion Hold Gate.
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
void Delete(void)
Delete the MotionController and all its objects.
MultiAxis * MultiAxisGet(int32_t motionSupervisorNumber)
MultiAxisGet returns a pointer to a MultiAxis object and initializes its internals.
int32_t SyncInterruptWait()
Suspend the current thread until an interrupt arrives from the controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
uint16_t MotionIdExecutingGet()
uint16_t MotionElementIdExecutingGet()
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.
void MotionIdSet(uint16_t id)
Set the Motion identifier.
RSIState StateGet()
Get the Axis or MultiAxis state.
void MotionHoldGateSet(bool hold)
Set the Motion Hold Gate.
void MovePT(RSIMotionType type, const double *const position, const double *const time, int32_t pointCount, int32_t emptyCount, bool retain, bool final)
A move commanded by a list of position and time points.
void EStopAbort()
E-Stop, then abort an axis.
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
@ RSIMotionTypePT
Position-Time algorithm with continuous position but discontinuous velocity. Best for short time inte...
@ RSIActionNONE
None - do not perform any action.
@ RSIStateIDLE
Idle, ready for anything.
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.