APIs, concepts, guides, and more

Basic template you can use to get up and running quick.

This application is designed to demonstrate simple Controller, Axis, MultiAxis, and I/O declaration. It can be a handy template for starting a RapidCode application.

Precondition
This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.) prior to running this program so that the motor can rotate in a stable manner.
Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.
1
17#include "rsi.h" // Import our RapidCode Library.
18#include "SampleAppsHelper.h" // Import our SampleApp helper functions.
19
20using namespace RSI::RapidCode; // Import the RapidCode namespace
21
23void TemplateMain(int argc, char *argv[])
24{
25 const int AXIS_X = (0);
26 const int AXIS_Y = (1);
27 const int IO_NODE = (7);
28
29 Axis *axisX;
30 Axis *axisY;
31 MultiAxis *multiAxisXY;
32 IO *io;
33
34 // Create and initialize RsiController class
35 MotionController *controller = MotionController::CreateFromSoftware();
37 try
38 {
39 // enable one MotionSupervisor for the MultiAxis
40 controller->MotionCountSet(controller->AxisCountGet() + 1);
41
42 // Get Axis X and Y respectively.
43 axisX = controller->AxisGet(AXIS_X);
45
46 axisY = controller->AxisGet(AXIS_Y);
48
49 // Initialize a MultiAxis, using the last MotionSupervisor.
50 multiAxisXY = controller->MultiAxisGet(controller->MotionCountGet() - 1);
52 multiAxisXY->AxisAdd(axisX);
53 multiAxisXY->AxisAdd(axisY);
54
55 // Initialize an IO.
56 io = controller->IOGet(IO_NODE);
57
58 // Insert your application code here.
59 }
60 catch (RsiError const& err)
61 {
62 printf("\n%s\n", err.text);
63 }
64 controller->Delete(); // Delete the controller as the program exits to ensure memory is deallocated in the correct order.
65 system("pause"); // Allow time to read Console.
66}
67
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5643
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 Delete(void)
Delete the MotionController and all its objects.
IO * IOGet(int32_t nodeNumber)
IOGet returns a pointer to an IO object using its node number and initializes its internals.
MultiAxis * MultiAxisGet(int32_t motionSupervisorNumber)
MultiAxisGet returns a pointer to a MultiAxis object and initializes its internals.
int32_t AxisCountGet()
Get the number of axes processing.
int32_t MotionCountGet()
Get the number of Motion Supervisors available in the firmware.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:796
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...
Definition rsi.h:10338
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
Definition rsi.h:107
static void CheckErrors(RapidCodeObject *rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...