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.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 15 14:23:48 2025
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 return false;
46 }
47 if (paramName =="LIMITS::jntPosMin")
48 {
49 return false;
50 }
51 if (paramName =="LIMITS::jntPosMax")
52 {
53 return false;
54 }
55 if (paramName =="COUPLING::actuatedAxesNames")
56 {
57 return false;
58 }
59 if (paramName =="COUPLING::actuatedAxesPosMin")
60 {
61 return false;
62 }
63 if (paramName =="COUPLING::actuatedAxesPosMax")
64 {
65 return false;
66 }
67
68 yError() <<"parameter '" << paramName << "' was not found";
69 return false;
70
71}
72
73
75{
76 //This is a sub-optimal solution.
77 //Ideally getConfiguration() should return all parameters but it is currently
78 //returning only user provided parameters (excluding default values)
79 //This behaviour will be fixed in the near future.
80 std::string s_cfg = m_provided_configuration;
81 return s_cfg;
82}
83
84bool CouplingICubEye_ParamsParser::parseParams(const yarp::os::Searchable & config)
85{
86 //Check for --help option
87 if (config.check("help"))
88 {
89 yCInfo(CouplingICubEyeParamsCOMPONENT) << getDocumentationOfDeviceParams();
90 }
91
92 m_provided_configuration = config.toString();
93 yarp::os::Property prop_check(m_provided_configuration.c_str());
94 //Parser of parameter jointNames
95 {
96 if (config.check("jointNames"))
97 {
98 {
99 m_jointNames.clear();
100 yarp::os::Bottle* tempBot = config.find("jointNames").asList();
101 if (tempBot)
102 {
103 std::string tempBots = tempBot->toString();
104 for (size_t i=0; i<tempBot->size(); i++)
105 {
106 m_jointNames.push_back(tempBot->get(i).asString());
107 }
108 }
109 else
110 {
111 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'jointNames' is not a properly formatted bottle";
112 }
113 }
114 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'jointNames' using value:" << m_jointNames;
115 }
116 else
117 {
118 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'jointNames' not found!";
119 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Names of the physical joints";
120 return false;
121 }
122 prop_check.unput("jointNames");
123 }
124
125 //Parser of parameter LIMITS::jntPosMin
126 {
127 yarp::os::Bottle sectionp;
128 sectionp = config.findGroup("LIMITS");
129 if (sectionp.check("jntPosMin"))
130 {
131 {
132 m_LIMITS_jntPosMin.clear();
133 yarp::os::Bottle* tempBot = sectionp.find("jntPosMin").asList();
134 if (tempBot)
135 {
136 std::string tempBots = tempBot->toString();
137 for (size_t i=0; i<tempBot->size(); i++)
138 {
139 m_LIMITS_jntPosMin.push_back(tempBot->get(i).asFloat64());
140 }
141 }
142 else
143 {
144 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'LIMITS_jntPosMin' is not a properly formatted bottle";
145 }
146 }
147 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'LIMITS::jntPosMin' using value:" << m_LIMITS_jntPosMin;
148 }
149 else
150 {
151 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'LIMITS::jntPosMin' not found!";
152 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Physical joints' position minimum";
153 return false;
154 }
155 prop_check.unput("LIMITS::jntPosMin");
156 }
157
158 //Parser of parameter LIMITS::jntPosMax
159 {
160 yarp::os::Bottle sectionp;
161 sectionp = config.findGroup("LIMITS");
162 if (sectionp.check("jntPosMax"))
163 {
164 {
165 m_LIMITS_jntPosMax.clear();
166 yarp::os::Bottle* tempBot = sectionp.find("jntPosMax").asList();
167 if (tempBot)
168 {
169 std::string tempBots = tempBot->toString();
170 for (size_t i=0; i<tempBot->size(); i++)
171 {
172 m_LIMITS_jntPosMax.push_back(tempBot->get(i).asFloat64());
173 }
174 }
175 else
176 {
177 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'LIMITS_jntPosMax' is not a properly formatted bottle";
178 }
179 }
180 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'LIMITS::jntPosMax' using value:" << m_LIMITS_jntPosMax;
181 }
182 else
183 {
184 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'LIMITS::jntPosMax' not found!";
185 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Physical joints' position maximum";
186 return false;
187 }
188 prop_check.unput("LIMITS::jntPosMax");
189 }
190
191 //Parser of parameter COUPLING::actuatedAxesNames
192 {
193 yarp::os::Bottle sectionp;
194 sectionp = config.findGroup("COUPLING");
195 if (sectionp.check("actuatedAxesNames"))
196 {
197 {
199 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesNames").asList();
200 if (tempBot)
201 {
202 std::string tempBots = tempBot->toString();
203 for (size_t i=0; i<tempBot->size(); i++)
204 {
205 m_COUPLING_actuatedAxesNames.push_back(tempBot->get(i).asString());
206 }
207 }
208 else
209 {
210 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesNames' is not a properly formatted bottle";
211 }
212 }
213 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesNames' using value:" << m_COUPLING_actuatedAxesNames;
214 }
215 else
216 {
217 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesNames' not found!";
218 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Names of the actuated axes";
219 return false;
220 }
221 prop_check.unput("COUPLING::actuatedAxesNames");
222 }
223
224 //Parser of parameter COUPLING::actuatedAxesPosMin
225 {
226 yarp::os::Bottle sectionp;
227 sectionp = config.findGroup("COUPLING");
228 if (sectionp.check("actuatedAxesPosMin"))
229 {
230 {
232 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesPosMin").asList();
233 if (tempBot)
234 {
235 std::string tempBots = tempBot->toString();
236 for (size_t i=0; i<tempBot->size(); i++)
237 {
238 m_COUPLING_actuatedAxesPosMin.push_back(tempBot->get(i).asFloat64());
239 }
240 }
241 else
242 {
243 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesPosMin' is not a properly formatted bottle";
244 }
245 }
246 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesPosMin' using value:" << m_COUPLING_actuatedAxesPosMin;
247 }
248 else
249 {
250 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesPosMin' not found!";
251 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Actuated axes' position minimum";
252 return false;
253 }
254 prop_check.unput("COUPLING::actuatedAxesPosMin");
255 }
256
257 //Parser of parameter COUPLING::actuatedAxesPosMax
258 {
259 yarp::os::Bottle sectionp;
260 sectionp = config.findGroup("COUPLING");
261 if (sectionp.check("actuatedAxesPosMax"))
262 {
263 {
265 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesPosMax").asList();
266 if (tempBot)
267 {
268 std::string tempBots = tempBot->toString();
269 for (size_t i=0; i<tempBot->size(); i++)
270 {
271 m_COUPLING_actuatedAxesPosMax.push_back(tempBot->get(i).asFloat64());
272 }
273 }
274 else
275 {
276 yCError(CouplingICubEyeParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesPosMax' is not a properly formatted bottle";
277 }
278 }
279 yCInfo(CouplingICubEyeParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesPosMax' using value:" << m_COUPLING_actuatedAxesPosMax;
280 }
281 else
282 {
283 yCError(CouplingICubEyeParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesPosMax' not found!";
284 yCError(CouplingICubEyeParamsCOMPONENT) << "Description of the parameter: Actuated axes' position maximum";
285 return false;
286 }
287 prop_check.unput("COUPLING::actuatedAxesPosMax");
288 }
289
290 /*
291 //This code check if the user set some parameter which are not check by the parser
292 //If the parser is set in strict mode, this will generate an error
293 if (prop_check.size() > 0)
294 {
295 bool extra_params_found = false;
296 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
297 {
298 if (m_parser_is_strict)
299 {
300 yCError(CouplingICubEyeParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
301 extra_params_found = true;
302 }
303 else
304 {
305 yCWarning(CouplingICubEyeParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
306 }
307 }
308
309 if (m_parser_is_strict && extra_params_found)
310 {
311 return false;
312 }
313 }
314 */
315 return true;
316}
317
318
320{
321 std::string doc;
322 doc = doc + std::string("\n=============================================\n");
323 doc = doc + std::string("This is the help for device: CouplingICubEye\n");
324 doc = doc + std::string("\n");
325 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
326 doc = doc + std::string("'jointNames': Names of the physical joints\n");
327 doc = doc + std::string("'LIMITS::jntPosMin': Physical joints' position minimum\n");
328 doc = doc + std::string("'LIMITS::jntPosMax': Physical joints' position maximum\n");
329 doc = doc + std::string("'COUPLING::actuatedAxesNames': Names of the actuated axes\n");
330 doc = doc + std::string("'COUPLING::actuatedAxesPosMin': Actuated axes' position minimum\n");
331 doc = doc + std::string("'COUPLING::actuatedAxesPosMax': Actuated axes' position maximum\n");
332 doc = doc + std::string("\n");
333 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
334 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";
335 doc = doc + std::string("Using only mandatory params:\n");
336 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";
337 doc = doc + std::string("=============================================\n\n"); return doc;
338}
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