#include <iostream>
#include <fstream>
#include "rsi.h"
#include "SampleAppsHelper.h"
#include "SampleApps.h"
int PathMotion::Run()
{
const int AXIS_COUNT = (2);
const int AXIS_X = 0;
const int AXIS_Y = 1;
const double USER_UNITS = 1048576;
const char* const PATH_MOTION_FILEPATH = "PathMotion.csv";
USE_HARDWARE = false;
double running_x = 0;
double running_y = 0;
double line_A[2] = { running_x, running_y };
running_x += -0.5;
double line_B[2] = { running_x, running_y };
running_y += -0.5;
double line_C[2] = { running_x, running_y };
running_y += (-0.25);
double arc_center_A[2] = { running_x,running_y };
running_x += (0.25);
running_x += -0.25;
double arc_center_B[2] = { running_x,running_y };
running_y += -0.25;
running_y += 0.25;
double arc_center_C[2] = { running_x,running_y };
running_x += -0.25;
running_x += 0.25;
double arc_center_D[2] = { running_x,running_y };
running_y += 0.25;
running_x += -0.5;
running_y += 0.5;
double line_D[2] = { running_x, running_y };
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);
std::ofstream myfile;
myfile.open(PATH_MOTION_FILEPATH);
myfile << "samples,x,y,\n";
controller->SampleWait(10);
}
myfile.close();
printf("\n%s\n", PATH_MOTION_FILEPATH);
}
{
printf(
"\n%s\n", err.
text);
return -1;
}
controller->Delete();
return 0;
}
double CommandPositionGet()
Get the current command position.
void AmpDisableActionSet(RSIMotorDisableAction action)
Set the Amp Disable action.
void SoftwareNegLimitActionSet(RSIAction action)
Set the action that will occur when the Software Negative Limit Event triggers.
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 Home()
Execute the homing routine.
void HomeMethodSet(RSIHomeMethod method)
Set the method to be used for homing.
void PositionSet(double position)
Set the Command and Actual positions.
void SoftwarePosLimitActionSet(RSIAction action)
Set the action that will occur when the Software Positive Limit Event triggers.
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 PathListStart(const double *const startPosition)
Start a line and arc point list for path motion.
void PathMotionStart()
Start the path motion.
void PathArcAdd(const double *const center, double angle)
Add an arc segment to the path.
void VectorDecelerationSet(double deceleration)
Set the vector deceleration.
void PathLineAdd(const double *const position)
Add a line segment to the path.
void PathBlendSet(bool blend)
Set the blending attribute.
void VectorAccelerationSet(double acceleration)
Set the vector acceleration.
void PathListEnd()
End a line and arc point list for path motion.
void AxisAdd(Axis *axis)
Add an Axis to a MultiAxis group.
void VectorVelocitySet(double velocity)
Set the vector velocity.
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.
bool MotionDoneGet()
Check to see if motion is done and settled.
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
@ RSIHomeMethodCURRENT_POSITION
@ RSIMotorDisableActionNONE
No action taken when disabled.
@ RSIActionNONE
None - do not perform any action.
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.