37 Component::defaultName =
"LaserScannerTimestampTest";
46 properties.topicName,
"TopicName",
"Name of the laserscanner topic to report to.");
48 def->component(laserScanUnitListenerPrx);
51 def->optional(properties.useTopic,
"useTopic",
"If enabled, will send data via topic.");
53 def->required(properties.frame,
"frame",
"Coordinate frame of the laserscanner.");
55 def->required(properties.freq,
"frequency",
"Default frequency of newly generated and published laser scans [Hz]");
57 def->required(properties.min,
"minOffset",
"Smallest allowed offset of wrong timestamps [ms]. May be negative. Offset for wrong generated timestamp randomly chosen from interval [minOffset,maxOffset]");
58 def->required(properties.max,
"maxOffset",
"Greatest allowed offset of wrong timestamps [ms]. May be negative. Offset for wrong generated timestamp randomly chosen from interval [minOffset,maxOffset]");
60 def->required(properties.correctBatchSize,
"MaxCorrectBatchSize",
"Maximum size of consecutive generated correct timestamps. Batch size of correct timestamps is randomly chosen from interval [1,MaxCorrectBatchSize]");
61 def->required(properties.wrongBatchSize,
"MaxWrongBatchSize",
"Maximum size of consecutive generated wrong timestamps. Batch size of wrong timestamps is randomly chosen from interval [1,MaxWrongBatchSize");
72 if (properties.min >= properties.max) {
73 ARMARX_ERROR <<
"following statement should be false but is not: min >= max";
76 if (properties.correctBatchSize < 1) {
77 ARMARX_ERROR <<
"following statement should be false but is not: correctBatchSize < 1";
80 if (properties.wrongBatchSize < 1) {
81 ARMARX_ERROR <<
"following statement should be false but is not: wrongBatchSize < 1";
85 if (properties.useTopic)
97 if (properties.useTopic)
99 getTopic(laserScanUnitListenerTopic, properties.topicName);
111 int scansUntilToggle = randInRange(1, properties.correctBatchSize);
112 bool correctScans =
true;
117 constexpr std::size_t nSamples = 1000;
119 armarx::LaserScan scanData;
120 for(std::size_t i = 0; i < nSamples; i++)
122 scanData.emplace_back(armarx::LaserScanStep {2 *
M_PI / nSamples, 2500.0F, 1.0f} );
128 scanTime += scanOffset;
135 if (laserScanUnitListenerTopic) {
136 laserScanUnitListenerTopic->reportSensorValues(properties.frame, properties.frame, scanData, scanT);
145 if (scansUntilToggle <= 0) {
147 scansUntilToggle = randInRange(1, properties.wrongBatchSize);
150 scansUntilToggle = randInRange(1, properties.correctBatchSize);
153 correctScans = !correctScans;
156 metronome.waitForNextTick();
160 int Component::randInRange(
int min,
int max) {
161 int size = (
max + 1) -
min;
162 int rand = std::rand();
164 return (rand % size) +
min;
183 return Component::defaultName;
190 return Component::defaultName;