APIs, concepts, guides, and more
RTTasksHelpers.h
Attention
See the following Concept pages for a detailed explanation of this sample: Real-Time Tasks.
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.
#ifndef RT_TASKS_HELPERS
#define RT_TASKS_HELPERS
#include "rttask.h"
#include <iostream>
#include <memory>
using namespace RSI::RapidCode; // Import our RapidCode namespace
using namespace RSI::RapidCode::RealTimeTasks; // Import the RealTimeTasks namespace
namespace RTTaskHelper
{
// Get the creation parameters for the task manager
#if defined(WIN32) && defined(NDEBUG)
// If we are on Windows and not Debug, then we need to create an INtime task manager
RTTaskManagerCreationParameters GetTaskManagerCreationParameters()
{
std::snprintf(
parameters.RTTaskDirectory,
RTTaskManagerCreationParameters::DirectoryLengthMaximum,
RMP_DEFAULT_PATH // The RMP install directory
);
parameters.Platform = PlatformType::INtime;
std::snprintf(
parameters.NodeName,
RTTaskManagerCreationParameters::NameLengthMaximum,
"NodeA"
);
return parameters;
}
#else
// Otherwise, we are on Linux or Debug, so we can create a native task manager
RTTaskManagerCreationParameters GetTaskManagerCreationParameters()
{
std::snprintf(
parameters.RTTaskDirectory,
RTTaskManagerCreationParameters::DirectoryLengthMaximum,
RMP_DEFAULT_PATH // The RMP install directory
);
// For Linux real-time set this to a isolated core
// parameters.CpuCore = -1;
return parameters;
}
#endif // defined(WIN32) && defined(NDEBUG)
// This calls a task to initialize the global variables and get pointers to RapidCode objects
// in the RTTaskFunctions library. It needs to be called before any task
// that uses RapidCode objects.
void InitializeRTTaskObjects(std::unique_ptr<RTTaskManager>& manager)
{
std::cout << "Running initialization task..." << std::endl;
RTTaskCreationParameters initParams("Initialize");
initParams.Repeats = RTTaskCreationParameters::RepeatNone;
std::unique_ptr<RTTask> task(manager->TaskSubmit(initParams));
constexpr int timeoutMs = 5000;
task->ExecutionCountAbsoluteWait(1, timeoutMs); // Wait for the task to execute once.
}
}
#endif // RT_TASKS_HELPERS
RTTaskCreationParameters specifies all the information required to create and configure a real-time t...
Definition rttask.h:124
int32_t Repeats
Number of times the task should execute (RepeatForever for infinite, 0 for none (one-shot)).
Definition rttask.h:168
RTTaskManagerCreationParameters specifies all the information required to create and configure an RTT...
Definition rttask.h:318
PlatformType Platform
Platform on which the manager firmware will run.
Definition rttask.h:329
char NodeName[NameLengthMaximum]
[INtime] Name of the node on which the manager will run.
Definition rttask.h:332
char RTTaskDirectory[DirectoryLengthMaximum]
Path to the directory containing the real-time task libraries.
Definition rttask.h:326