RMP Motion Controller
10.7.1
APIs
, concepts, guides, and more
Community
Support
Contact
rttaskfunctions.cpp
1
#include "rttaskglobals.h"
2
3
#include <cstdlib>
4
#include <ctime>
5
6
#include <iostream>
7
8
using namespace
RSI::RapidCode
;
9
using namespace
RSI::RapidCode::RealTimeTasks
;
10
12
// initialize the global data and random number generator
13
RSI_TASK(Initialize)
14
{
15
data->counter = 0;
16
data->average = 0;
17
18
std::srand(std::time(
nullptr
));
19
}
21
23
// increment the counter in the global data
24
RSI_TASK(Increment)
25
{
26
data->counter += 1;
27
}
29
31
// randomly move the axis back and forth
32
RSI_TASK(RandomWalk)
33
{
34
int
random = std::rand() % 2;
35
double
step = random ? 0.05 : -0.025;
// randomly increment or decrement the average
36
data->average += step;
37
data->counter += 1;
38
39
RTAxisGet(0)->MoveSCurve(data->average);
40
}
RSI::RapidCode::RealTimeTasks
The RealTimeTasks namespace.
Definition
rttask.h:36
RSI::RapidCode
RapidStuff
SampleApps
RTTaskFunctions
src
rttaskfunctions.cpp
Generated by
1.15.0