APIs, concepts, guides, and more
rttasks-helpers.h
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.
#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,
RMP_INSTALL_PATH // the rmp install directory
);
std::snprintf(
parameters.NodeName,
"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,
RMP_INSTALL_PATH // the rmp install directory
);
// for linux real-time set this to an 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 SubmitInitializationTask(RTTaskManager &manager)
{
std::cout << "Running initialization task..." << std::endl;
RTTaskCreationParameters initParams("Initialize");
RTTask task = manager.TaskSubmit(initParams);
constexpr int timeoutMs = 5000;
task.ExecutionCountAbsoluteWait(1, timeoutMs); // wait for the task to execute once.
}
}
#endif // RT_TASKS_HELPERS
int64_t ExecutionCountAbsoluteWait(int64_t count=ExecutionCountDefault, int32_t timeoutMs=ExecutionCountWaitTimeoutMillisecondsDefault)
Wait for the task to reach a specific execution count.
Interface for controlling and monitoring a single real-time task. See RTTaskManager::TaskSubmit and R...
Definition rttask.h:435
RTTask TaskSubmit(const RTTaskCreationParameters &parameters)
Submit a new task to the manager using creation parameters.
Interface for managing real-time tasks firmware. See Real-Time Tasks for more information.
Definition rttask.h:559
The RealTimeTasks namespace.
Definition rttask.h:36
RTTaskCreationParameters specifies all the information required to create and configure a real-time t...
Definition rttask.h:126
int32_t Repeats
Number of times the task should execute (RepeatForever for infinite, 0 for none (one-shot)).
Definition rttask.h:170
static constexpr int32_t RepeatNone
Special value to indicate the task should not repeat.
Definition rttask.h:143
RTTaskManagerCreationParameters specifies all the information required to create and configure an RTT...
Definition rttask.h:320
PlatformType Platform
Platform on which the manager firmware will run.
Definition rttask.h:342
static constexpr int32_t DirectoryLengthMaximum
Maximum length of the directory path.
Definition rttask.h:322
char NodeName[NameLengthMaximum]
[INtime] Name of the node on which the manager will run. By default, this is set to (and verified as)...
Definition rttask.h:346
char RTTaskDirectory[DirectoryLengthMaximum]
Path to the directory containing the real-time task libraries.
Definition rttask.h:339
static constexpr int32_t NameLengthMaximum
Maximum length of name fields (node name, user label).
Definition rttask.h:325