YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ControlBoard_nwc_yarp_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 (2.2)
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_GENERATION is ON.
10
11// Generated on: Tue Jul 28 23:33:23 2026
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(ControlBoard_nwc_yarpParamsCOMPONENT, "yarp.device.ControlBoard_nwc_yarp")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("remote");
32 params.push_back("local");
33 params.push_back("writeStrict");
34 params.push_back("carrier");
35 params.push_back("carrier_cmd");
36 params.push_back("timeout");
37 params.push_back("use_streaming");
38 params.push_back("local_qos::enable");
39 params.push_back("local_qos::thread_priority");
40 params.push_back("local_qos::thread_policy");
41 params.push_back("local_qos::packet_priority");
42 params.push_back("remote_qos::enable");
43 params.push_back("remote_qos::thread_priority");
44 params.push_back("remote_qos::thread_policy");
45 params.push_back("remote_qos::packet_priority");
46 params.push_back("diagnostic");
47 return params;
48}
49
50
51bool ControlBoard_nwc_yarp_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
52{
53 if (paramName =="remote")
54 {
55 paramValue = m_remote;
56 return true;
57 }
58 if (paramName =="local")
59 {
60 paramValue = m_local;
61 return true;
62 }
63 if (paramName =="writeStrict")
64 {
65 paramValue = m_writeStrict;
66 return true;
67 }
68 if (paramName =="carrier")
69 {
70 paramValue = m_carrier;
71 return true;
72 }
73 if (paramName =="carrier_cmd")
74 {
75 paramValue = m_carrier_cmd;
76 return true;
77 }
78 if (paramName =="timeout")
79 {
80 paramValue = std::to_string(m_timeout);
81 return true;
82 }
83 if (paramName =="use_streaming")
84 {
85 if (m_use_streaming==true) paramValue = "true";
86 else paramValue = "false";
87 return true;
88 }
89 if (paramName =="local_qos::enable")
90 {
91 if (m_local_qos_enable==true) paramValue = "true";
92 else paramValue = "false";
93 return true;
94 }
95 if (paramName =="local_qos::thread_priority")
96 {
97 paramValue = std::to_string(m_local_qos_thread_priority);
98 return true;
99 }
100 if (paramName =="local_qos::thread_policy")
101 {
102 paramValue = std::to_string(m_local_qos_thread_policy);
103 return true;
104 }
105 if (paramName =="local_qos::packet_priority")
106 {
107 paramValue = m_local_qos_packet_priority;
108 return true;
109 }
110 if (paramName =="remote_qos::enable")
111 {
112 if (m_remote_qos_enable==true) paramValue = "true";
113 else paramValue = "false";
114 return true;
115 }
116 if (paramName =="remote_qos::thread_priority")
117 {
118 paramValue = std::to_string(m_remote_qos_thread_priority);
119 return true;
120 }
121 if (paramName =="remote_qos::thread_policy")
122 {
123 paramValue = std::to_string(m_remote_qos_thread_policy);
124 return true;
125 }
126 if (paramName =="remote_qos::packet_priority")
127 {
128 paramValue = m_remote_qos_packet_priority;
129 return true;
130 }
131 if (paramName =="diagnostic")
132 {
133 if (m_diagnostic==true) paramValue = "true";
134 else paramValue = "false";
135 return true;
136 }
137
138 yError() <<"parameter '" << paramName << "' was not found";
139 return false;
140
141}
142
143
145{
146 //This is a sub-optimal solution.
147 //Ideally getConfiguration() should return all parameters but it is currently
148 //returning only user provided parameters (excluding default values)
149 //This behaviour will be fixed in the near future.
150 std::string s_cfg = m_provided_configuration;
151 return s_cfg;
152}
153
155{
156 //Check for --help option
157 if (config.check("help"))
158 {
159 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << getDocumentationOfDeviceParams();
160 }
161
164 //Parser of parameter remote
165 {
166 if (config.check("remote"))
167 {
168 m_remote = config.find("remote").asString();
169 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote' using value:" << m_remote;
170 }
171 else
172 {
173 yCError(ControlBoard_nwc_yarpParamsCOMPONENT) << "Mandatory parameter 'remote' not found!";
174 yCError(ControlBoard_nwc_yarpParamsCOMPONENT) << "Description of the parameter: Prefix of the port to which to connect.";
175 return false;
176 }
177 prop_check.unput("remote");
178 }
179
180 //Parser of parameter local
181 {
182 if (config.check("local"))
183 {
184 m_local = config.find("local").asString();
185 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local' using value:" << m_local;
186 }
187 else
188 {
189 yCError(ControlBoard_nwc_yarpParamsCOMPONENT) << "Mandatory parameter 'local' not found!";
190 yCError(ControlBoard_nwc_yarpParamsCOMPONENT) << "Description of the parameter: Port prefix of the port opened by this device.";
191 return false;
192 }
193 prop_check.unput("local");
194 }
195
196 //Parser of parameter writeStrict
197 {
198 if (config.check("writeStrict"))
199 {
200 m_writeStrict = config.find("writeStrict").asString();
201 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'writeStrict' using value:" << m_writeStrict;
202 }
203 else
204 {
205 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'writeStrict' using DEFAULT value:" << m_writeStrict;
206 }
207 prop_check.unput("writeStrict");
208 }
209
210 //Parser of parameter carrier
211 {
212 if (config.check("carrier"))
213 {
214 m_carrier = config.find("carrier").asString();
215 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'carrier' using value:" << m_carrier;
216 }
217 else
218 {
219 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'carrier' using DEFAULT value:" << m_carrier;
220 }
221 prop_check.unput("carrier");
222 }
223
224 //Parser of parameter carrier_cmd
225 {
226 if (config.check("carrier_cmd"))
227 {
228 m_carrier_cmd = config.find("carrier_cmd").asString();
229 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'carrier_cmd' using value:" << m_carrier_cmd;
230 }
231 else
232 {
233 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'carrier_cmd' using DEFAULT value:" << m_carrier_cmd;
234 }
235 prop_check.unput("carrier_cmd");
236 }
237
238 //Parser of parameter timeout
239 {
240 if (config.check("timeout"))
241 {
242 m_timeout = config.find("timeout").asFloat32();
243 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'timeout' using value:" << m_timeout;
244 }
245 else
246 {
247 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'timeout' using DEFAULT value:" << m_timeout;
248 }
249 prop_check.unput("timeout");
250 }
251
252 //Parser of parameter use_streaming
253 {
254 if (config.check("use_streaming"))
255 {
256 m_use_streaming = config.find("use_streaming").asBool();
257 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'use_streaming' using value:" << m_use_streaming;
258 }
259 else
260 {
261 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'use_streaming' using DEFAULT value:" << m_use_streaming;
262 }
263 prop_check.unput("use_streaming");
264 }
265
266 //Parser of parameter local_qos::enable
267 {
268 yarp::os::Bottle sectionp;
269 sectionp = config.findGroup("local_qos");
270 if (sectionp.check("enable"))
271 {
272 m_local_qos_enable = sectionp.find("enable").asBool();
273 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local_qos::enable' using value:" << m_local_qos_enable;
274 }
275 else
276 {
277 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local_qos::enable' using DEFAULT value:" << m_local_qos_enable;
278 }
279 prop_check.unput("local_qos::enable");
280 }
281
282 //Parser of parameter local_qos::thread_priority
283 {
284 yarp::os::Bottle sectionp;
285 sectionp = config.findGroup("local_qos");
286 if (sectionp.check("thread_priority"))
287 {
288 m_local_qos_thread_priority = sectionp.find("thread_priority").asInt64();
289 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local_qos::thread_priority' using value:" << m_local_qos_thread_priority;
290 }
291 else
292 {
293 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local_qos::thread_priority' using DEFAULT value:" << m_local_qos_thread_priority;
294 }
295 prop_check.unput("local_qos::thread_priority");
296 }
297
298 //Parser of parameter local_qos::thread_policy
299 {
300 yarp::os::Bottle sectionp;
301 sectionp = config.findGroup("local_qos");
302 if (sectionp.check("thread_policy"))
303 {
304 m_local_qos_thread_policy = sectionp.find("thread_policy").asInt64();
305 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local_qos::thread_policy' using value:" << m_local_qos_thread_policy;
306 }
307 else
308 {
309 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local_qos::thread_policy' using DEFAULT value:" << m_local_qos_thread_policy;
310 }
311 prop_check.unput("local_qos::thread_policy");
312 }
313
314 //Parser of parameter local_qos::packet_priority
315 {
316 yarp::os::Bottle sectionp;
317 sectionp = config.findGroup("local_qos");
318 if (sectionp.check("packet_priority"))
319 {
320 m_local_qos_packet_priority = sectionp.find("packet_priority").asString();
321 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local_qos::packet_priority' using value:" << m_local_qos_packet_priority;
322 }
323 else
324 {
325 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'local_qos::packet_priority' using DEFAULT value:" << m_local_qos_packet_priority;
326 }
327 prop_check.unput("local_qos::packet_priority");
328 }
329
330 //Parser of parameter remote_qos::enable
331 {
332 yarp::os::Bottle sectionp;
333 sectionp = config.findGroup("remote_qos");
334 if (sectionp.check("enable"))
335 {
336 m_remote_qos_enable = sectionp.find("enable").asBool();
337 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote_qos::enable' using value:" << m_remote_qos_enable;
338 }
339 else
340 {
341 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote_qos::enable' using DEFAULT value:" << m_remote_qos_enable;
342 }
343 prop_check.unput("remote_qos::enable");
344 }
345
346 //Parser of parameter remote_qos::thread_priority
347 {
348 yarp::os::Bottle sectionp;
349 sectionp = config.findGroup("remote_qos");
350 if (sectionp.check("thread_priority"))
351 {
352 m_remote_qos_thread_priority = sectionp.find("thread_priority").asInt64();
353 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote_qos::thread_priority' using value:" << m_remote_qos_thread_priority;
354 }
355 else
356 {
357 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote_qos::thread_priority' using DEFAULT value:" << m_remote_qos_thread_priority;
358 }
359 prop_check.unput("remote_qos::thread_priority");
360 }
361
362 //Parser of parameter remote_qos::thread_policy
363 {
364 yarp::os::Bottle sectionp;
365 sectionp = config.findGroup("remote_qos");
366 if (sectionp.check("thread_policy"))
367 {
368 m_remote_qos_thread_policy = sectionp.find("thread_policy").asInt64();
369 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote_qos::thread_policy' using value:" << m_remote_qos_thread_policy;
370 }
371 else
372 {
373 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote_qos::thread_policy' using DEFAULT value:" << m_remote_qos_thread_policy;
374 }
375 prop_check.unput("remote_qos::thread_policy");
376 }
377
378 //Parser of parameter remote_qos::packet_priority
379 {
380 yarp::os::Bottle sectionp;
381 sectionp = config.findGroup("remote_qos");
382 if (sectionp.check("packet_priority"))
383 {
384 m_remote_qos_packet_priority = sectionp.find("packet_priority").asString();
385 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote_qos::packet_priority' using value:" << m_remote_qos_packet_priority;
386 }
387 else
388 {
389 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'remote_qos::packet_priority' using DEFAULT value:" << m_remote_qos_packet_priority;
390 }
391 prop_check.unput("remote_qos::packet_priority");
392 }
393
394 //Parser of parameter diagnostic
395 {
396 if (config.check("diagnostic"))
397 {
398 m_diagnostic = config.find("diagnostic").asBool();
399 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'diagnostic' using value:" << m_diagnostic;
400 }
401 else
402 {
403 yCInfo(ControlBoard_nwc_yarpParamsCOMPONENT) << "Parameter 'diagnostic' using DEFAULT value:" << m_diagnostic;
404 }
405 prop_check.unput("diagnostic");
406 }
407
408 /*
409 //This code check if the user set some parameter which are not check by the parser
410 //If the parser is set in strict mode, this will generate an error
411 if (prop_check.size() > 0)
412 {
413 bool extra_params_found = false;
414 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
415 {
416 if (m_parser_is_strict)
417 {
418 yCError(ControlBoard_nwc_yarpParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
419 extra_params_found = true;
420 }
421 else
422 {
423 yCWarning(ControlBoard_nwc_yarpParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
424 }
425 }
426
427 if (m_parser_is_strict && extra_params_found)
428 {
429 return false;
430 }
431 }
432 */
433 return true;
434}
435
436
438{
439 std::string doc;
440 doc = doc + std::string("\n=============================================\n");
441 doc = doc + std::string("This is the help for device: ControlBoard_nwc_yarp\n");
442 doc = doc + std::string("\n");
443 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
444 doc = doc + std::string("'remote': Prefix of the port to which to connect.\n");
445 doc = doc + std::string("'local': Port prefix of the port opened by this device.\n");
446 doc = doc + std::string("'writeStrict': It can be 'on' or 'off'\n");
447 doc = doc + std::string("'carrier': carrier used for receiving streamed robot state\n");
448 doc = doc + std::string("'carrier_cmd': carrier used for sending streamed commands\n");
449 doc = doc + std::string("'timeout': timeout for the input port which receives the streamed robot state\n");
450 doc = doc + std::string("'use_streaming': enable/disables the use of streaming commands. If disabled, rpc is used instead\n");
451 doc = doc + std::string("'local_qos::enable': Enable the usage of local Qos\n");
452 doc = doc + std::string("'local_qos::thread_priority': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
453 doc = doc + std::string("'local_qos::thread_policy': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
454 doc = doc + std::string("'local_qos::packet_priority': Local Qos. See https://yarp.it/latest/channelprioritization.html\n");
455 doc = doc + std::string("'remote_qos::enable': Enable the usage of remote Qos\n");
456 doc = doc + std::string("'remote_qos::thread_priority': Remote Qos. See https://yarp.it/latest/channelprioritization.html\n");
457 doc = doc + std::string("'remote_qos::thread_policy': Remote Qos. See https://yarp.it/latest/channelprioritization.html.\n");
458 doc = doc + std::string("'remote_qos::packet_priority': Remote Qos. See https://yarp.it/latest/channelprioritization.html.\n");
459 doc = doc + std::string("'diagnostic': For development purpose only\n");
460 doc = doc + std::string("\n");
461 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
462 doc = doc + " yarpdev --device controlBoard_nwc_yarp --remote <mandatory_value> --local <mandatory_value> --writeStrict <optional_value> --carrier fast_tcp --carrier_cmd fast_tcp --timeout 0.5 --use_streaming true --local_qos::enable false --local_qos::thread_priority 0 --local_qos::thread_policy 0 --local_qos::packet_priority <optional_value> --remote_qos::enable false --remote_qos::thread_priority 0 --remote_qos::thread_policy 0 --remote_qos::packet_priority <optional_value> --diagnostic false\n";
463 doc = doc + std::string("Using only mandatory params:\n");
464 doc = doc + " yarpdev --device controlBoard_nwc_yarp --remote <mandatory_value> --local <mandatory_value>\n";
465 doc = doc + std::string("=============================================\n\n"); return doc;
466}
#define yError(...)
Definition Log.h:361
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
std::string getConfiguration() const override
Return the configuration of the device.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition Bottle.cpp:283
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition Bottle.cpp:293
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.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
virtual std::int64_t asInt64() const
Get 64-bit integer value.
Definition Value.cpp:216
virtual bool asBool() const
Get boolean value.
Definition Value.cpp:192
virtual std::string asString() const
Get string value.
Definition Value.cpp:246
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)