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