36 const std::string Component::defaultName =
"LaserScannerTimestampTest";
45 properties.topicName,
"TopicName",
"Name of the laserscanner topic to report to.");
47 def->component(laserScanUnitListenerPrx);
50 def->optional(properties.useTopic,
"useTopic",
"If enabled, will send data via topic.");
52 def->required(properties.frame,
"frame",
"Coordinate frame of the laserscanner.");
54 def->required(properties.freq,
56 "Default frequency of newly generated and published laser scans [Hz]");
61 "Smallest allowed offset of wrong timestamps [ms]. May be negative. Offset for wrong "
62 "generated timestamp randomly chosen from interval [minOffset,maxOffset]");
66 "Greatest allowed offset of wrong timestamps [ms]. May be negative. Offset for wrong "
67 "generated timestamp randomly chosen from interval [minOffset,maxOffset]");
70 properties.correctBatchSize,
71 "MaxCorrectBatchSize",
72 "Maximum size of consecutive generated correct timestamps. Batch size of correct "
73 "timestamps is randomly chosen from interval [1,MaxCorrectBatchSize]");
74 def->required(properties.wrongBatchSize,
76 "Maximum size of consecutive generated wrong timestamps. Batch size of wrong "
77 "timestamps is randomly chosen from interval [1,MaxWrongBatchSize");
87 if (properties.min >= properties.max)
89 ARMARX_ERROR <<
"following statement should be false but is not: min >= max";
92 if (properties.correctBatchSize < 1)
94 ARMARX_ERROR <<
"following statement should be false but is not: correctBatchSize < 1";
97 if (properties.wrongBatchSize < 1)
99 ARMARX_ERROR <<
"following statement should be false but is not: wrongBatchSize < 1";
103 if (properties.useTopic)
114 if (properties.useTopic)
116 getTopic(laserScanUnitListenerTopic, properties.topicName);
128 int scansUntilToggle = randInRange(1, properties.correctBatchSize);
129 bool correctScans =
true;
134 constexpr std::size_t nSamples = 1000;
136 armarx::LaserScan scanData;
137 for (std::size_t i = 0; i < nSamples; i++)
139 scanData.emplace_back(armarx::LaserScanStep{2 *
M_PI / nSamples, 2500.0F, 1.0f});
145 armarx::Duration scanOffset =
147 scanTime += scanOffset;
154 if (laserScanUnitListenerTopic)
156 laserScanUnitListenerTopic->reportSensorValues(
157 properties.frame, properties.frame, scanData, scanT);
166 if (scansUntilToggle <= 0)
170 scansUntilToggle = randInRange(1, properties.wrongBatchSize);
175 scansUntilToggle = randInRange(1, properties.correctBatchSize);
178 correctScans = !correctScans;
181 metronome.waitForNextTick();
186 Component::randInRange(
int min,
int max)
188 int size = (
max + 1) -
min;
189 int rand = std::rand();
191 return (rand % size) +
min;
208 return Component::defaultName;
214 return Component::defaultName;
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
void onInitComponent() override
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
static std::string GetDefaultName()
Get the component's default name.
void onExitComponent() override
std::string getDefaultName() const override
Default component property definition container.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
static Frequency Hertz(std::int64_t hertz)
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
TopicProxyType getTopic(const std::string &name)
Returns a proxy of the specified topic.
std::int64_t toMilliSeconds() const
Returns the amount of milliseconds.
Simple rate limiter for use in loops to maintain a certain frequency given a clock.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
This file is part of ArmarX.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< TimestampVariant > TimestampVariantPtr