YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeFrameGrabber_ParamsParser.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6
7// Generated by yarpDeviceParamParserGenerator (1.0)
8// This is an automatically generated file. Please do not edit it.
9// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON.
10
11// Generated on: Mon Sep 16 16:44:50 2024
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(FakeFrameGrabberParamsCOMPONENT, "yarp.device.FakeFrameGrabber")
20}
21
22
24{
25 //Default value of parameterrectificationMatrix
26 {
28 yarp::os::Value tempVal;
30 yarp::os::Bottle* tempBot = tempVal.asList();
31 if (tempBot && tempBot->size()!=0)
32 {
33 for (size_t i=0; i<tempBot->size(); i++)
34 {
35 m_rectificationMatrix.push_back(tempBot->get(i).asFloat64());
36 }
37 }
38 else
39 {
40 yError() <<"parameter 'rectificationMatrix' is not a properly formatted bottle";
41 }
42 }
43
44}
45
46
47std::vector<std::string> FakeFrameGrabber_ParamsParser::getListOfParams() const
48{
49 std::vector<std::string> params;
50 params.push_back("width");
51 params.push_back("height");
52 params.push_back("horizontalFov");
53 params.push_back("verticalFov");
54 params.push_back("fakeFrameGrabber_rpc_port");
55 params.push_back("mirror");
56 params.push_back("syncro");
57 params.push_back("topIsLow");
58 params.push_back("physFocalLength");
59 params.push_back("focalLengthX");
60 params.push_back("focalLengthY");
61 params.push_back("principalPointX");
62 params.push_back("principalPointY");
63 params.push_back("distortionModel");
64 params.push_back("k1");
65 params.push_back("k2");
66 params.push_back("k3");
67 params.push_back("t1");
68 params.push_back("t2");
69 params.push_back("freq");
70 params.push_back("period");
71 params.push_back("mode");
72 params.push_back("src");
73 params.push_back("add_timestamp");
74 params.push_back("add_noise");
75 params.push_back("bayer");
76 params.push_back("mono");
77 params.push_back("snr");
78 params.push_back("rectificationMatrix");
79 return params;
80}
81
82
84{
85 //Check for --help option
86 if (config.check("help"))
87 {
88 yCInfo(FakeFrameGrabberParamsCOMPONENT) << getDocumentationOfDeviceParams();
89 }
90
91 std::string config_string = config.toString();
92 yarp::os::Property prop_check(config_string.c_str());
93 //Parser of parameter width
94 {
95 if (config.check("width"))
96 {
97 m_width = config.find("width").asInt64();
98 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'width' using value:" << m_width;
99 }
100 else
101 {
102 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'width' using DEFAULT value:" << m_width;
103 }
104 prop_check.unput("width");
105 }
106
107 //Parser of parameter height
108 {
109 if (config.check("height"))
110 {
111 m_height = config.find("height").asInt64();
112 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'height' using value:" << m_height;
113 }
114 else
115 {
116 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'height' using DEFAULT value:" << m_height;
117 }
118 prop_check.unput("height");
119 }
120
121 //Parser of parameter horizontalFov
122 {
123 if (config.check("horizontalFov"))
124 {
125 m_horizontalFov = config.find("horizontalFov").asFloat64();
126 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'horizontalFov' using value:" << m_horizontalFov;
127 }
128 else
129 {
130 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'horizontalFov' using DEFAULT value:" << m_horizontalFov;
131 }
132 prop_check.unput("horizontalFov");
133 }
134
135 //Parser of parameter verticalFov
136 {
137 if (config.check("verticalFov"))
138 {
139 m_verticalFov = config.find("verticalFov").asFloat64();
140 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'verticalFov' using value:" << m_verticalFov;
141 }
142 else
143 {
144 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'verticalFov' using DEFAULT value:" << m_verticalFov;
145 }
146 prop_check.unput("verticalFov");
147 }
148
149 //Parser of parameter fakeFrameGrabber_rpc_port
150 {
151 if (config.check("fakeFrameGrabber_rpc_port"))
152 {
153 m_fakeFrameGrabber_rpc_port = config.find("fakeFrameGrabber_rpc_port").asString();
154 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'fakeFrameGrabber_rpc_port' using value:" << m_fakeFrameGrabber_rpc_port;
155 }
156 else
157 {
158 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'fakeFrameGrabber_rpc_port' using DEFAULT value:" << m_fakeFrameGrabber_rpc_port;
159 }
160 prop_check.unput("fakeFrameGrabber_rpc_port");
161 }
162
163 //Parser of parameter mirror
164 {
165 if (config.check("mirror"))
166 {
167 m_mirror = config.find("mirror").asBool();
168 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'mirror' using value:" << m_mirror;
169 }
170 else
171 {
172 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'mirror' using DEFAULT value:" << m_mirror;
173 }
174 prop_check.unput("mirror");
175 }
176
177 //Parser of parameter syncro
178 {
179 if (config.check("syncro"))
180 {
181 m_syncro = config.find("syncro").asBool();
182 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'syncro' using value:" << m_syncro;
183 }
184 else
185 {
186 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'syncro' using DEFAULT value:" << m_syncro;
187 }
188 prop_check.unput("syncro");
189 }
190
191 //Parser of parameter physFocalLength
192 {
193 if (config.check("physFocalLength"))
194 {
195 m_physFocalLength = config.find("physFocalLength").asFloat64();
196 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'physFocalLength' using value:" << m_physFocalLength;
197 }
198 else
199 {
200 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'physFocalLength' using DEFAULT value:" << m_physFocalLength;
201 }
202 prop_check.unput("physFocalLength");
203 }
204
205 //Parser of parameter focalLengthX
206 {
207 if (config.check("focalLengthX"))
208 {
209 m_focalLengthX = config.find("focalLengthX").asFloat64();
210 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'focalLengthX' using value:" << m_focalLengthX;
211 }
212 else
213 {
214 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'focalLengthX' using DEFAULT value:" << m_focalLengthX;
215 }
216 prop_check.unput("focalLengthX");
217 }
218
219 //Parser of parameter focalLengthY
220 {
221 if (config.check("focalLengthY"))
222 {
223 m_focalLengthY = config.find("focalLengthY").asFloat64();
224 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'focalLengthY' using value:" << m_focalLengthY;
225 }
226 else
227 {
228 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'focalLengthY' using DEFAULT value:" << m_focalLengthY;
229 }
230 prop_check.unput("focalLengthY");
231 }
232
233 //Parser of parameter principalPointX
234 {
235 if (config.check("principalPointX"))
236 {
237 m_principalPointX = config.find("principalPointX").asFloat64();
238 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'principalPointX' using value:" << m_principalPointX;
239 }
240 else
241 {
242 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'principalPointX' using DEFAULT value:" << m_principalPointX;
243 }
244 prop_check.unput("principalPointX");
245 }
246
247 //Parser of parameter principalPointY
248 {
249 if (config.check("principalPointY"))
250 {
251 m_principalPointY = config.find("principalPointY").asFloat64();
252 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'principalPointY' using value:" << m_principalPointY;
253 }
254 else
255 {
256 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'principalPointY' using DEFAULT value:" << m_principalPointY;
257 }
258 prop_check.unput("principalPointY");
259 }
260
261 //Parser of parameter distortionModel
262 {
263 if (config.check("distortionModel"))
264 {
265 m_distortionModel = config.find("distortionModel").asString();
266 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'distortionModel' using value:" << m_distortionModel;
267 }
268 else
269 {
270 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'distortionModel' using DEFAULT value:" << m_distortionModel;
271 }
272 prop_check.unput("distortionModel");
273 }
274
275 //Parser of parameter k1
276 {
277 if (config.check("k1"))
278 {
279 m_k1 = config.find("k1").asFloat64();
280 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'k1' using value:" << m_k1;
281 }
282 else
283 {
284 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'k1' using DEFAULT value:" << m_k1;
285 }
286 prop_check.unput("k1");
287 }
288
289 //Parser of parameter k2
290 {
291 if (config.check("k2"))
292 {
293 m_k2 = config.find("k2").asFloat64();
294 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'k2' using value:" << m_k2;
295 }
296 else
297 {
298 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'k2' using DEFAULT value:" << m_k2;
299 }
300 prop_check.unput("k2");
301 }
302
303 //Parser of parameter k3
304 {
305 if (config.check("k3"))
306 {
307 m_k3 = config.find("k3").asFloat64();
308 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'k3' using value:" << m_k3;
309 }
310 else
311 {
312 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'k3' using DEFAULT value:" << m_k3;
313 }
314 prop_check.unput("k3");
315 }
316
317 //Parser of parameter t1
318 {
319 if (config.check("t1"))
320 {
321 m_t1 = config.find("t1").asFloat64();
322 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 't1' using value:" << m_t1;
323 }
324 else
325 {
326 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 't1' using DEFAULT value:" << m_t1;
327 }
328 prop_check.unput("t1");
329 }
330
331 //Parser of parameter t2
332 {
333 if (config.check("t2"))
334 {
335 m_t2 = config.find("t2").asFloat64();
336 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 't2' using value:" << m_t2;
337 }
338 else
339 {
340 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 't2' using DEFAULT value:" << m_t2;
341 }
342 prop_check.unput("t2");
343 }
344
345 //Parser of parameter freq
346 {
347 if (config.check("freq"))
348 {
349 m_freq = config.find("freq").asFloat64();
350 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'freq' using value:" << m_freq;
351 }
352 else
353 {
354 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'freq' using DEFAULT value:" << m_freq;
355 }
356 prop_check.unput("freq");
357 }
358
359 //Parser of parameter period
360 {
361 if (config.check("period"))
362 {
363 m_period = config.find("period").asFloat64();
364 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
365 }
366 else
367 {
368 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
369 }
370 prop_check.unput("period");
371 }
372
373 //Parser of parameter mode
374 {
375 if (config.check("mode"))
376 {
377 m_mode = config.find("mode").asString();
378 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'mode' using value:" << m_mode;
379 }
380 else
381 {
382 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'mode' using DEFAULT value:" << m_mode;
383 }
384 prop_check.unput("mode");
385 }
386
387 //Parser of parameter src
388 {
389 if (config.check("src"))
390 {
391 m_src = config.find("src").asString();
392 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'src' using value:" << m_src;
393 }
394 else
395 {
396 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'src' using DEFAULT value:" << m_src;
397 }
398 prop_check.unput("src");
399 }
400
401 //Parser of parameter add_timestamp
402 {
403 if (config.check("add_timestamp"))
404 {
405 m_add_timestamp = config.find("add_timestamp").asBool();
406 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'add_timestamp' using value:" << m_add_timestamp;
407 }
408 else
409 {
410 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'add_timestamp' using DEFAULT value:" << m_add_timestamp;
411 }
412 prop_check.unput("add_timestamp");
413 }
414
415 //Parser of parameter add_noise
416 {
417 if (config.check("add_noise"))
418 {
419 m_add_noise = config.find("add_noise").asBool();
420 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'add_noise' using value:" << m_add_noise;
421 }
422 else
423 {
424 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'add_noise' using DEFAULT value:" << m_add_noise;
425 }
426 prop_check.unput("add_noise");
427 }
428
429 //Parser of parameter bayer
430 {
431 if (config.check("bayer"))
432 {
433 m_bayer = config.find("bayer").asBool();
434 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'bayer' using value:" << m_bayer;
435 }
436 else
437 {
438 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'bayer' using DEFAULT value:" << m_bayer;
439 }
440 prop_check.unput("bayer");
441 }
442
443 //Parser of parameter mono
444 {
445 if (config.check("mono"))
446 {
447 m_mono = config.find("mono").asBool();
448 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'mono' using value:" << m_mono;
449 }
450 else
451 {
452 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'mono' using DEFAULT value:" << m_mono;
453 }
454 prop_check.unput("mono");
455 }
456
457 //Parser of parameter snr
458 {
459 if (config.check("snr"))
460 {
461 m_snr = config.find("snr").asFloat64();
462 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'snr' using value:" << m_snr;
463 }
464 else
465 {
466 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'snr' using DEFAULT value:" << m_snr;
467 }
468 prop_check.unput("snr");
469 }
470
471 //Parser of parameter rectificationMatrix
472 {
473 if (config.check("rectificationMatrix"))
474 {
475 {
476 m_rectificationMatrix.clear();
477 yarp::os::Bottle* tempBot = config.find("rectificationMatrix").asList();
478 if (tempBot)
479 {
480 std::string tempBots = tempBot->toString();
481 for (size_t i=0; i<tempBot->size(); i++)
482 {
483 m_rectificationMatrix.push_back(tempBot->get(i).asFloat64());
484 }
485 }
486 else
487 {
488 yCError(FakeFrameGrabberParamsCOMPONENT) <<"parameter 'rectificationMatrix' is not a properly formatted bottle";
489 }
490 }
491 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'rectificationMatrix' using value:" << m_rectificationMatrix;
492 }
493 else
494 {
495 yCInfo(FakeFrameGrabberParamsCOMPONENT) << "Parameter 'rectificationMatrix' using DEFAULT value:" << m_rectificationMatrix;
496 }
497 prop_check.unput("rectificationMatrix");
498 }
499
500 /*
501 //This code check if the user set some parameter which are not check by the parser
502 //If the parser is set in strict mode, this will generate an error
503 if (prop_check.size() > 0)
504 {
505 bool extra_params_found = false;
506 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
507 {
508 if (m_parser_is_strict)
509 {
510 yCError(FakeFrameGrabberParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
511 extra_params_found = true;
512 }
513 else
514 {
515 yCWarning(FakeFrameGrabberParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
516 }
517 }
518
519 if (m_parser_is_strict && extra_params_found)
520 {
521 return false;
522 }
523 }
524 */
525 return true;
526}
527
528
530{
531 std::string doc;
532 doc = doc + std::string("\n=============================================\n");
533 doc = doc + std::string("This is the help for device: FakeFrameGrabber\n");
534 doc = doc + std::string("\n");
535 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
536 doc = doc + std::string("'width': desired width of test image\n");
537 doc = doc + std::string("'height': desired height of test image\n");
538 doc = doc + std::string("'horizontalFov': desired horizontal fov of test image\n");
539 doc = doc + std::string("'verticalFov': desired horizontal fov of test image\n");
540 doc = doc + std::string("'fakeFrameGrabber_rpc_port': rpc port for the fakeFrameGrabber\n");
541 doc = doc + std::string("'mirror': mirror height of test image\n");
542 doc = doc + std::string("'syncro': synchronize producer and consumer, so that all images are used once and only once\n");
543 doc = doc + std::string("'topIsLow': explicitly set the topIsLow field in the images\n");
544 doc = doc + std::string("'physFocalLength': Physical focal length\n");
545 doc = doc + std::string("'focalLengthX': Horizontal component of the focal length\n");
546 doc = doc + std::string("'focalLengthY': Vertical component of the focal length\n");
547 doc = doc + std::string("'principalPointX': X coordinate of the principal point\n");
548 doc = doc + std::string("'principalPointY': Y coordinate of the principal point\n");
549 doc = doc + std::string("'distortionModel': Reference to group of parameters describing the distortion model of the camera\n");
550 doc = doc + std::string("'k1': Radial distortion coefficient of the lens(fake\n");
551 doc = doc + std::string("'k2': Radial distortion coefficient of the lens(fake)\n");
552 doc = doc + std::string("'k3': Radial distortion coefficient of the lens(fake)\n");
553 doc = doc + std::string("'t1': Tangential distortion of the lens(fake)\n");
554 doc = doc + std::string("'t2': Tangential distortion of the lens(fake)\n");
555 doc = doc + std::string("'freq': rate of test images in Hz\n");
556 doc = doc + std::string("'period': period of test images in seconds\n");
557 doc = doc + std::string("'mode': bouncy [ball], scrolly [line], grid [grid], grid multisize [size], random [rand], none [none], time test[time]\n");
558 doc = doc + std::string("'src': background image to use, if any\n");
559 doc = doc + std::string("'add_timestamp': should write the timestamp in the first bytes of the image\n");
560 doc = doc + std::string("'add_noise': should add noise to the image (uses snr parameter)\n");
561 doc = doc + std::string("'bayer': should emit bayer test image\n");
562 doc = doc + std::string("'mono': should emit a monochrome image\n");
563 doc = doc + std::string("'snr': Signal noise ratio ([0.0-1.0]\n");
564 doc = doc + std::string("'rectificationMatrix': Matrix that describes the lens' distortion\n");
565 doc = doc + std::string("\n");
566 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
567 doc = doc + " yarpdev --device fakeFrameGrabber --width 320 --height 240 --horizontalFov 1.0 --verticalFov 2.0 --fakeFrameGrabber_rpc_port /fakeFrameGrabber/rpc --mirror false --syncro false --topIsLow true --physFocalLength 3.0 --focalLengthX 4.0 --focalLengthY 5.0 --principalPointX 6.0 --principalPointY 7.0 --distortionModel FishEye --k1 8.0 --k2 9.0 --k3 10.0 --t1 11.0 --t2 12.0 --freq 0 --period 0 --mode [line] --src <optional_value> --add_timestamp false --add_noise false --bayer false --mono false --snr 0.5 --rectificationMatrix \" (1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0) \"\n";
568 doc = doc + std::string("Using only mandatory params:\n");
569 doc = doc + " yarpdev --device fakeFrameGrabber\n";
570 doc = doc + std::string("=============================================\n\n"); return doc;
571}
#define yError(...)
Definition Log.h:361
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
size_type size() const
Gets the number of elements in the bottle.
Definition Bottle.cpp:251
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:246
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:211
A class for storing options and configuration information.
Definition Property.h:33
void unput(const std::string &key)
Remove the association from the given key to a value, if present.
A base class for nested structures that can be searched.
Definition Searchable.h:31
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
A single value (typically within a Bottle).
Definition Value.h:43
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition Value.cpp:222
virtual Bottle * asList() const
Get list value.
Definition Value.cpp:240
void fromString(const char *str)
Set value to correspond to a textual representation.
Definition Value.cpp:351
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)