RMP Motion Controller
10.7.1
APIs
, concepts, guides, and more
Community
Support
Contact
rttaskfunctions.cpp
1
10
#include "rttaskglobals.h"
11
12
#include <cstdlib>
13
#include <ctime>
14
15
#include <iostream>
16
17
using namespace
RSI::RapidCode
;
18
using namespace
RSI::RapidCode::RealTimeTasks
;
19
21
// This task initializes the global data and the random number generator
22
RSI_TASK(Initialize)
23
{
24
data->counter = 0;
25
data->average = 0;
26
27
std::srand(std::time(
nullptr
));
28
}
30
32
// This task increments the counter in the global data
33
RSI_TASK(Increment)
34
{
35
data->counter += 1;
36
}
38
40
// This task randomly moves the axis back and forth
41
RSI_TASK(RandomWalk)
42
{
43
int
random = std::rand() % 2;
44
double
step = random ? 0.05 : -0.025;
// Randomly increment or decrement the average
45
data->average += step;
46
data->counter += 1;
47
48
RTAxisGet(0)->MoveSCurve(data->average);
49
}
RSI::RapidCode::RealTimeTasks
The RealTimeTasks namespace.
Definition
rttaskglobals.h:68
RSI::RapidCode
RapidStuff
SampleApps
RTTaskFunctions
src
rttaskfunctions.cpp
Generated by
1.10.0