YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeLaser_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:14 2026
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(FakeLaserParamsCOMPONENT, "yarp.device.FakeLaser")
20}
21
22
26
27
28std::vector<std::string> FakeLaser_ParamsParser::getListOfParams() const
29{
30 std::vector<std::string> params;
31 params.push_back("test");
32 params.push_back("rpc_test_port");
33 params.push_back("localization_port");
34 params.push_back("localization_server");
35 params.push_back("localization_client");
36 params.push_back("localization_device");
37 params.push_back("MAP_MODE::map_file");
38 params.push_back("MAP_MODE::map_context");
39 params.push_back("clip_max");
40 params.push_back("clip_min");
41 params.push_back("GENERAL::period");
42 params.push_back("CONSTANT_MODE::const_distance");
43 return params;
44}
45
46
47bool FakeLaser_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
48{
49 if (paramName =="test")
50 {
51 paramValue = m_test;
52 return true;
53 }
54 if (paramName =="rpc_test_port")
55 {
56 paramValue = m_rpc_test_port;
57 return true;
58 }
59 if (paramName =="localization_port")
60 {
61 paramValue = m_localization_port;
62 return true;
63 }
64 if (paramName =="localization_server")
65 {
66 paramValue = m_localization_server;
67 return true;
68 }
69 if (paramName =="localization_client")
70 {
71 paramValue = m_localization_client;
72 return true;
73 }
74 if (paramName =="localization_device")
75 {
76 paramValue = m_localization_device;
77 return true;
78 }
79 if (paramName =="MAP_MODE::map_file")
80 {
81 paramValue = m_MAP_MODE_map_file;
82 return true;
83 }
84 if (paramName =="MAP_MODE::map_context")
85 {
86 paramValue = m_MAP_MODE_map_context;
87 return true;
88 }
89 if (paramName =="clip_max")
90 {
91 paramValue = std::to_string(m_clip_max);
92 return true;
93 }
94 if (paramName =="clip_min")
95 {
96 paramValue = std::to_string(m_clip_min);
97 return true;
98 }
99 if (paramName =="GENERAL::period")
100 {
101 paramValue = std::to_string(m_GENERAL_period);
102 return true;
103 }
104 if (paramName =="CONSTANT_MODE::const_distance")
105 {
106 paramValue = std::to_string(m_CONSTANT_MODE_const_distance);
107 return true;
108 }
109
110 yError() <<"parameter '" << paramName << "' was not found";
111 return false;
112
113}
114
115
117{
118 //This is a sub-optimal solution.
119 //Ideally getConfiguration() should return all parameters but it is currently
120 //returning only user provided parameters (excluding default values)
121 //This behaviour will be fixed in the near future.
122 std::string s_cfg = m_provided_configuration;
123 return s_cfg;
124}
125
127{
128 //Check for --help option
129 if (config.check("help"))
130 {
131 yCInfo(FakeLaserParamsCOMPONENT) << getDocumentationOfDeviceParams();
132 }
133
136 //Parser of parameter test
137 {
138 if (config.check("test"))
139 {
140 m_test = config.find("test").asString();
141 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'test' using value:" << m_test;
142 }
143 else
144 {
145 yCError(FakeLaserParamsCOMPONENT) << "Mandatory parameter 'test' not found!";
146 yCError(FakeLaserParamsCOMPONENT) << "Description of the parameter: Choose the modality";
147 return false;
148 }
149 prop_check.unput("test");
150 }
151
152 //Parser of parameter rpc_test_port
153 {
154 if (config.check("rpc_test_port"))
155 {
156 m_rpc_test_port = config.find("rpc_test_port").asString();
157 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'rpc_test_port' using value:" << m_rpc_test_port;
158 }
159 else
160 {
161 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'rpc_test_port' using DEFAULT value:" << m_rpc_test_port;
162 }
163 prop_check.unput("rpc_test_port");
164 }
165
166 //Parser of parameter localization_port
167 {
168 if (config.check("localization_port"))
169 {
170 m_localization_port = config.find("localization_port").asString();
171 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'localization_port' using value:" << m_localization_port;
172 }
173 else
174 {
175 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'localization_port' using DEFAULT value:" << m_localization_port;
176 }
177 prop_check.unput("localization_port");
178 }
179
180 //Parser of parameter localization_server
181 {
182 if (config.check("localization_server"))
183 {
184 m_localization_server = config.find("localization_server").asString();
185 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'localization_server' using value:" << m_localization_server;
186 }
187 else
188 {
189 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'localization_server' using DEFAULT value:" << m_localization_server;
190 }
191 prop_check.unput("localization_server");
192 }
193
194 //Parser of parameter localization_client
195 {
196 if (config.check("localization_client"))
197 {
198 m_localization_client = config.find("localization_client").asString();
199 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'localization_client' using value:" << m_localization_client;
200 }
201 else
202 {
203 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'localization_client' using DEFAULT value:" << m_localization_client;
204 }
205 prop_check.unput("localization_client");
206 }
207
208 //Parser of parameter localization_device
209 {
210 if (config.check("localization_device"))
211 {
212 m_localization_device = config.find("localization_device").asString();
213 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'localization_device' using value:" << m_localization_device;
214 }
215 else
216 {
217 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'localization_device' using DEFAULT value:" << m_localization_device;
218 }
219 prop_check.unput("localization_device");
220 }
221
222 //Parser of parameter MAP_MODE::map_file
223 {
224 yarp::os::Bottle sectionp;
225 sectionp = config.findGroup("MAP_MODE");
226 if (sectionp.check("map_file"))
227 {
228 m_MAP_MODE_map_file = sectionp.find("map_file").asString();
229 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'MAP_MODE::map_file' using value:" << m_MAP_MODE_map_file;
230 }
231 else
232 {
233 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'MAP_MODE::map_file' using DEFAULT value:" << m_MAP_MODE_map_file;
234 }
235 prop_check.unput("MAP_MODE::map_file");
236 }
237
238 //Parser of parameter MAP_MODE::map_context
239 {
240 yarp::os::Bottle sectionp;
241 sectionp = config.findGroup("MAP_MODE");
242 if (sectionp.check("map_context"))
243 {
244 m_MAP_MODE_map_context = sectionp.find("map_context").asString();
245 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'MAP_MODE::map_context' using value:" << m_MAP_MODE_map_context;
246 }
247 else
248 {
249 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'MAP_MODE::map_context' using DEFAULT value:" << m_MAP_MODE_map_context;
250 }
251 prop_check.unput("MAP_MODE::map_context");
252 }
253
254 //Parser of parameter clip_max
255 {
256 if (config.check("clip_max"))
257 {
258 m_clip_max = config.find("clip_max").asFloat64();
259 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'clip_max' using value:" << m_clip_max;
260 }
261 else
262 {
263 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'clip_max' using DEFAULT value:" << m_clip_max;
264 }
265 prop_check.unput("clip_max");
266 }
267
268 //Parser of parameter clip_min
269 {
270 if (config.check("clip_min"))
271 {
272 m_clip_min = config.find("clip_min").asFloat64();
273 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'clip_min' using value:" << m_clip_min;
274 }
275 else
276 {
277 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'clip_min' using DEFAULT value:" << m_clip_min;
278 }
279 prop_check.unput("clip_min");
280 }
281
282 //Parser of parameter GENERAL::period
283 {
284 yarp::os::Bottle sectionp;
285 sectionp = config.findGroup("GENERAL");
286 if (sectionp.check("period"))
287 {
288 m_GENERAL_period = sectionp.find("period").asFloat64();
289 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'GENERAL::period' using value:" << m_GENERAL_period;
290 }
291 else
292 {
293 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'GENERAL::period' using DEFAULT value:" << m_GENERAL_period;
294 }
295 prop_check.unput("GENERAL::period");
296 }
297
298 //Parser of parameter CONSTANT_MODE::const_distance
299 {
300 yarp::os::Bottle sectionp;
301 sectionp = config.findGroup("CONSTANT_MODE");
302 if (sectionp.check("const_distance"))
303 {
304 m_CONSTANT_MODE_const_distance = sectionp.find("const_distance").asFloat64();
305 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'CONSTANT_MODE::const_distance' using value:" << m_CONSTANT_MODE_const_distance;
306 }
307 else
308 {
309 yCInfo(FakeLaserParamsCOMPONENT) << "Parameter 'CONSTANT_MODE::const_distance' using DEFAULT value:" << m_CONSTANT_MODE_const_distance;
310 }
311 prop_check.unput("CONSTANT_MODE::const_distance");
312 }
313
314 /*
315 //This code check if the user set some parameter which are not check by the parser
316 //If the parser is set in strict mode, this will generate an error
317 if (prop_check.size() > 0)
318 {
319 bool extra_params_found = false;
320 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
321 {
322 if (m_parser_is_strict)
323 {
324 yCError(FakeLaserParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
325 extra_params_found = true;
326 }
327 else
328 {
329 yCWarning(FakeLaserParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
330 }
331 }
332
333 if (m_parser_is_strict && extra_params_found)
334 {
335 return false;
336 }
337 }
338 */
339 return true;
340}
341
342
344{
345 std::string doc;
346 doc = doc + std::string("\n=============================================\n");
347 doc = doc + std::string("This is the help for device: FakeLaser\n");
348 doc = doc + std::string("\n");
349 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
350 doc = doc + std::string("'test': Choose the modality\n");
351 doc = doc + std::string("'rpc_test_port': Full name of the rpc port on which user can send different test commands\n");
352 doc = doc + std::string("'localization_port': Full name of the port to which device connects to receive the localization data\n");
353 doc = doc + std::string("'localization_server': Full name of the port to which device connects to receive the localization data\n");
354 doc = doc + std::string("'localization_client': Full name of the local transformClient opened by the device\n");
355 doc = doc + std::string("'localization_device': Type of localization device, e.g. localization2DClient, localization2D_nwc_yarp\n");
356 doc = doc + std::string("'MAP_MODE::map_file': Full path to a .map file\n");
357 doc = doc + std::string("'MAP_MODE::map_context': Full path to a .map file\n");
358 doc = doc + std::string("'clip_max': Maximum detectable distance for an obstacle\n");
359 doc = doc + std::string("'clip_min': Minimum detectable distance for an obstacle\n");
360 doc = doc + std::string("'GENERAL::period': Thread period\n");
361 doc = doc + std::string("'CONSTANT_MODE::const_distance': Default const distance for mode use_constant\n");
362 doc = doc + std::string("\n");
363 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
364 doc = doc + " yarpdev --device fakeLaser --test use_pattern --rpc_test_port /fakeLaser/rpc:i --localization_port /fakeLaser/location:i --localization_server /localizationServer --localization_client /fakeLaser/localizationClient --localization_device localization2DClient --MAP_MODE::map_file <optional_value> --MAP_MODE::map_context <optional_value> --clip_max 3.5 --clip_min 0.1 --GENERAL::period 0.02 --CONSTANT_MODE::const_distance 1\n";
365 doc = doc + std::string("Using only mandatory params:\n");
366 doc = doc + " yarpdev --device fakeLaser --test use_pattern\n";
367 doc = doc + std::string("=============================================\n\n"); return doc;
368}
#define yError(...)
Definition Log.h:361
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.
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.
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 yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition Value.cpp:228
virtual std::string asString() const
Get string value.
Definition Value.cpp:246
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)