iCub-main
Loading...
Searching...
No Matches
CouplingICubEye_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: Mon Aug 31 14:52:24 2026
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(CouplingICubEyeParamsCOMPONENT, "yarp.device.CouplingICubEye")
20}
21
22
26
27
28std::vector<std::string> CouplingICubEye_ParamsParser::getListOfParams() const
29{
30 std::vector<std::string> params;
31 params.push_back("jointNames");
32 params.push_back("LIMITS::jntPosMin");
33 params.push_back("LIMITS::jntPosMax");
34 params.push_back("COUPLING::actuatedAxesNames");
35 params.push_back("COUPLING::actuatedAxesPosMin");
36 params.push_back("COUPLING::actuatedAxesPosMax");
37 return params;
38}
39
40
41bool CouplingICubEye_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
42{
43 if (paramName =="jointNames")
44 {
45 std::ostringstream oss;
46 oss << "( ";
47 for (auto x : m_jointNames)
48 {
49 oss << x << " ";
50 }
51 oss << " )";
52 paramValue = oss.str();
53 return true;
54 }
55 if (paramName =="LIMITS::jntPosMin")
56 {
57 std::ostringstream oss;
58 oss << "( ";
59 for (auto x : m_LIMITS_jntPosMin)
60 {
61 oss << x << " ";
62 }
63 oss << " )";
64 paramValue = oss.str();
65 return true;
66 }
67 if (paramName =="LIMITS::jntPosMax")
68 {
69 std::ostringstream oss;
70 oss << "( ";
71 for (auto x : m_LIMITS_jntPosMax)
72 {
73 oss << x << " ";
74 }
75 oss << " )";
76 paramValue = oss.str();
77 return true;
78 }
79 if (paramName =="COUPLING::actuatedAxesNames")
80 {
81 std::ostringstream oss;
82 oss << "( ";
84 {
85 oss << x << " ";
86 }
87 oss << " )";
88 paramValue = oss.str();
89 return true;
90 }
91 if (paramName =="COUPLING::actuatedAxesPosMin")
92 {
93 std::ostringstream oss;
94 oss << "( ";
96 {
97 oss << x << " ";
98 }
99 oss << " )";
100 paramValue = oss.str();
101 return true;
102 }
103 if (paramName =="COUPLING::actuatedAxesPosMax")
104 {
105 std::ostringstream oss;
106 oss << "( ";
108 {
109 oss << x << " ";
110 }
111 oss << " )";
112 paramValue = oss.str();
113 return true;
114 }
115
116 yError() <<"parameter '" << paramName << "' was not found";
117 return false;
118
119}
120
121
123{
124 //This is a sub-optimal solution.
125 //Ideally getConfiguration() should return all parameters but it is currently
126 //returning only user provided parameters (excluding default values)
127 //This behaviour will be fixed in the near future.
128 std::string s_cfg = m_provided_configuration;
129 return s_cfg;
130}
131
132bool CouplingICubEye_ParamsParser::parseParams(const yarp::os::Searchable & config)
133{
134 //Check for --help option
135 if (config.check("help"))
136 {
137 yCInfo(CouplingICubEyeParamsCOMPONENT) << getDocumentationOfDeviceParams();
138 }
139
140 m_provided_configuration = config.toString();
141 yarp::os::Property prop_check(m_provided_configuration.c_str());
142 //Parser of parameter jointNames
143 {
144 if (config.check("jointNames"))
145 {
146 {
147 m_jointNames.clear();
148 yarp::os::Bottle* tempBot = config.find("jointNames").asList();
149 if (tempBot)
150 {
151 std::string tempBots = tempBot->toString();
152 for (size_t i=0; i<tempBot->size(); i++)
153 {
154 m_jointNames.push_back(tempBot->get(i).asString());
155 }
156 }
157 else
158 {
159 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'jointNames' is not a properly formatted bottle";
160 }
161 }
162 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'jointNames' using value:" << m_jointNames;
163 }
164 else
165 {
166 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'jointNames' not found!";
167 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Names of the physical joints";
168 return false;
169 }
170 prop_check.unput("jointNames");
171 }
172
173 //Parser of parameter LIMITS::jntPosMin
174 {
175 yarp::os::Bottle sectionp;
176 sectionp = config.findGroup("LIMITS");
177 if (sectionp.check("jntPosMin"))
178 {
179 {
180 m_LIMITS_jntPosMin.clear();
181 yarp::os::Bottle* tempBot = sectionp.find("jntPosMin").asList();
182 if (tempBot)
183 {
184 std::string tempBots = tempBot->toString();
185 for (size_t i=0; i<tempBot->size(); i++)
186 {
187 m_LIMITS_jntPosMin.push_back(tempBot->get(i).asFloat64());
188 }
189 }
190 else
191 {
192 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'LIMITS_jntPosMin' is not a properly formatted bottle";
193 }
194 }
195 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'LIMITS::jntPosMin' using value:" << m_LIMITS_jntPosMin;
196 }
197 else
198 {
199 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'LIMITS::jntPosMin' not found!";
200 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Physical joints' position minimum";
201 return false;
202 }
203 prop_check.unput("LIMITS::jntPosMin");
204 }
205
206 //Parser of parameter LIMITS::jntPosMax
207 {
208 yarp::os::Bottle sectionp;
209 sectionp = config.findGroup("LIMITS");
210 if (sectionp.check("jntPosMax"))
211 {
212 {
213 m_LIMITS_jntPosMax.clear();
214 yarp::os::Bottle* tempBot = sectionp.find("jntPosMax").asList();
215 if (tempBot)
216 {
217 std::string tempBots = tempBot->toString();
218 for (size_t i=0; i<tempBot->size(); i++)
219 {
220 m_LIMITS_jntPosMax.push_back(tempBot->get(i).asFloat64());
221 }
222 }
223 else
224 {
225 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'LIMITS_jntPosMax' is not a properly formatted bottle";
226 }
227 }
228 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'LIMITS::jntPosMax' using value:" << m_LIMITS_jntPosMax;
229 }
230 else
231 {
232 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'LIMITS::jntPosMax' not found!";
233 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Physical joints' position maximum";
234 return false;
235 }
236 prop_check.unput("LIMITS::jntPosMax");
237 }
238
239 //Parser of parameter COUPLING::actuatedAxesNames
240 {
241 yarp::os::Bottle sectionp;
242 sectionp = config.findGroup("COUPLING");
243 if (sectionp.check("actuatedAxesNames"))
244 {
245 {
247 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesNames").asList();
248 if (tempBot)
249 {
250 std::string tempBots = tempBot->toString();
251 for (size_t i=0; i<tempBot->size(); i++)
252 {
253 m_COUPLING_actuatedAxesNames.push_back(tempBot->get(i).asString());
254 }
255 }
256 else
257 {
258 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesNames' is not a properly formatted bottle";
259 }
260 }
261 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesNames' using value:" << m_COUPLING_actuatedAxesNames;
262 }
263 else
264 {
265 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesNames' not found!";
266 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Names of the actuated axes";
267 return false;
268 }
269 prop_check.unput("COUPLING::actuatedAxesNames");
270 }
271
272 //Parser of parameter COUPLING::actuatedAxesPosMin
273 {
274 yarp::os::Bottle sectionp;
275 sectionp = config.findGroup("COUPLING");
276 if (sectionp.check("actuatedAxesPosMin"))
277 {
278 {
280 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesPosMin").asList();
281 if (tempBot)
282 {
283 std::string tempBots = tempBot->toString();
284 for (size_t i=0; i<tempBot->size(); i++)
285 {
286 m_COUPLING_actuatedAxesPosMin.push_back(tempBot->get(i).asFloat64());
287 }
288 }
289 else
290 {
291 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesPosMin' is not a properly formatted bottle";
292 }
293 }
294 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesPosMin' using value:" << m_COUPLING_actuatedAxesPosMin;
295 }
296 else
297 {
298 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesPosMin' not found!";
299 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Actuated axes' position minimum";
300 return false;
301 }
302 prop_check.unput("COUPLING::actuatedAxesPosMin");
303 }
304
305 //Parser of parameter COUPLING::actuatedAxesPosMax
306 {
307 yarp::os::Bottle sectionp;
308 sectionp = config.findGroup("COUPLING");
309 if (sectionp.check("actuatedAxesPosMax"))
310 {
311 {
313 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesPosMax").asList();
314 if (tempBot)
315 {
316 std::string tempBots = tempBot->toString();
317 for (size_t i=0; i<tempBot->size(); i++)
318 {
319 m_COUPLING_actuatedAxesPosMax.push_back(tempBot->get(i).asFloat64());
320 }
321 }
322 else
323 {
324 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesPosMax' is not a properly formatted bottle";
325 }
326 }
327 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesPosMax' using value:" << m_COUPLING_actuatedAxesPosMax;
328 }
329 else
330 {
331 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesPosMax' not found!";
332 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Actuated axes' position maximum";
333 return false;
334 }
335 prop_check.unput("COUPLING::actuatedAxesPosMax");
336 }
337
338 /*
339 //This code check if the user set some parameter which are not check by the parser
340 //If the parser is set in strict mode, this will generate an error
341 if (prop_check.size() > 0)
342 {
343 bool extra_params_found = false;
344 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
345 {
346 if (m_parser_is_strict)
347 {
348 yCError(CouplingICubEyeParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
349 extra_params_found = true;
350 }
351 else
352 {
353 yCWarning(CouplingICubEyeParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
354 }
355 }
356
357 if (m_parser_is_strict && extra_params_found)
358 {
359 return false;
360 }
361 }
362 */
363 return true;
364}
365
366
368{
369 std::string doc;
370 doc = doc + std::string("\n=============================================\n");
371 doc = doc + std::string("This is the help for device: CouplingICubEye\n");
372 doc = doc + std::string("\n");
373 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
374 doc = doc + std::string("'jointNames': Names of the physical joints\n");
375 doc = doc + std::string("'LIMITS::jntPosMin': Physical joints' position minimum\n");
376 doc = doc + std::string("'LIMITS::jntPosMax': Physical joints' position maximum\n");
377 doc = doc + std::string("'COUPLING::actuatedAxesNames': Names of the actuated axes\n");
378 doc = doc + std::string("'COUPLING::actuatedAxesPosMin': Actuated axes' position minimum\n");
379 doc = doc + std::string("'COUPLING::actuatedAxesPosMax': Actuated axes' position maximum\n");
380 doc = doc + std::string("\n");
381 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
382 doc = doc + " yarpdev --device couplingICubEye --jointNames <mandatory_value> --LIMITS::jntPosMin <mandatory_value> --LIMITS::jntPosMax <mandatory_value> --COUPLING::actuatedAxesNames <mandatory_value> --COUPLING::actuatedAxesPosMin <mandatory_value> --COUPLING::actuatedAxesPosMax <mandatory_value>\n";
383 doc = doc + std::string("Using only mandatory params:\n");
384 doc = doc + " yarpdev --device couplingICubEye --jointNames <mandatory_value> --LIMITS::jntPosMin <mandatory_value> --LIMITS::jntPosMax <mandatory_value> --COUPLING::actuatedAxesNames <mandatory_value> --COUPLING::actuatedAxesPosMin <mandatory_value> --COUPLING::actuatedAxesPosMax <mandatory_value>\n";
385 doc = doc + std::string("=============================================\n\n"); return doc;
386}
std::string getDocumentationOfDeviceParams() const override
bool parseParams(const yarp::os::Searchable &config) override
std::vector< std::string > m_jointNames
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
std::vector< double > m_COUPLING_actuatedAxesPosMin
std::string getConfiguration() const override
std::vector< std::string > m_COUPLING_actuatedAxesNames
std::vector< std::string > getListOfParams() const override
std::vector< double > m_COUPLING_actuatedAxesPosMax