APIs, concepts, guides, and more
rttaskfunctions.cpp
Note
See Real-Time Tasks 📜 for a detailed explanation of this sample code.
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.
#include "rttaskglobals.h"
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace RSI::RapidCode;
// initialize the global data and random number generator
RSI_TASK(Initialize)
{
data->counter = 0;
data->average = 0;
std::srand(std::time(nullptr));
}
// increment the counter in the global data
RSI_TASK(Increment)
{
data->counter += 1;
}
// randomly move the axis back and forth
RSI_TASK(RandomWalk)
{
int random = std::rand() % 2;
double step = random ? 0.05 : -0.025; // randomly increment or decrement the average
data->average += step;
data->counter += 1;
RTAxisGet(0)->MoveSCurve(data->average);
}
The RealTimeTasks namespace.
Definition rttask.h:36