iCub-main
Loading...
Searching...
No Matches
CouplingICubHandMk2_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 (1.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: Fri Nov 29 12:03:55 2024
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(CouplingICubHandMk2ParamsCOMPONENT, "yarp.device.CouplingICubHandMk2")
20}
21
22
26
27
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::device");
35 params.push_back("COUPLING::actuatedAxesNames");
36 params.push_back("COUPLING::actuatedAxesPosMin");
37 params.push_back("COUPLING::actuatedAxesPosMax");
38 return params;
39}
40
41
42bool CouplingICubHandMk2_ParamsParser::parseParams(const yarp::os::Searchable & config)
43{
44 //Check for --help option
45 if (config.check("help"))
46 {
47 yCInfo(CouplingICubHandMk2ParamsCOMPONENT) << getDocumentationOfDeviceParams();
48 }
49
50 std::string config_string = config.toString();
51 yarp::os::Property prop_check(config_string.c_str());
52 //Parser of parameter jointNames
53 {
54 if (config.check("jointNames"))
55 {
56 {
57 m_jointNames.clear();
58 yarp::os::Bottle* tempBot = config.find("jointNames").asList();
59 if (tempBot)
60 {
61 std::string tempBots = tempBot->toString();
62 for (size_t i=0; i<tempBot->size(); i++)
63 {
64 m_jointNames.push_back(tempBot->get(i).asString());
65 }
66 }
67 else
68 {
69 yCError(CouplingICubHandMk2ParamsCOMPONENT) <<"parameter 'jointNames' is not a properly formatted bottle";
70 }
71 }
72 yCInfo(CouplingICubHandMk2ParamsCOMPONENT) << "Parameter 'jointNames' using value:" << m_jointNames;
73 }
74 else
75 {
76 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Mandatory parameter 'jointNames' not found!";
77 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Description of the parameter: Names of the physical joints";
78 return false;
79 }
80 prop_check.unput("jointNames");
81 }
82
83 //Parser of parameter LIMITS::jntPosMin
84 {
85 yarp::os::Bottle sectionp;
86 sectionp = config.findGroup("LIMITS");
87 if (sectionp.check("jntPosMin"))
88 {
89 {
90 m_LIMITS_jntPosMin.clear();
91 yarp::os::Bottle* tempBot = sectionp.find("jntPosMin").asList();
92 if (tempBot)
93 {
94 std::string tempBots = tempBot->toString();
95 for (size_t i=0; i<tempBot->size(); i++)
96 {
97 m_LIMITS_jntPosMin.push_back(tempBot->get(i).asFloat64());
98 }
99 }
100 else
101 {
102 yCError(CouplingICubHandMk2ParamsCOMPONENT) <<"parameter 'LIMITS_jntPosMin' is not a properly formatted bottle";
103 }
104 }
105 yCInfo(CouplingICubHandMk2ParamsCOMPONENT) << "Parameter 'LIMITS::jntPosMin' using value:" << m_LIMITS_jntPosMin;
106 }
107 else
108 {
109 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Mandatory parameter 'LIMITS::jntPosMin' not found!";
110 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Description of the parameter: Physical joints' position minimum";
111 return false;
112 }
113 prop_check.unput("LIMITS::jntPosMin");
114 }
115
116 //Parser of parameter LIMITS::jntPosMax
117 {
118 yarp::os::Bottle sectionp;
119 sectionp = config.findGroup("LIMITS");
120 if (sectionp.check("jntPosMax"))
121 {
122 {
123 m_LIMITS_jntPosMax.clear();
124 yarp::os::Bottle* tempBot = sectionp.find("jntPosMax").asList();
125 if (tempBot)
126 {
127 std::string tempBots = tempBot->toString();
128 for (size_t i=0; i<tempBot->size(); i++)
129 {
130 m_LIMITS_jntPosMax.push_back(tempBot->get(i).asFloat64());
131 }
132 }
133 else
134 {
135 yCError(CouplingICubHandMk2ParamsCOMPONENT) <<"parameter 'LIMITS_jntPosMax' is not a properly formatted bottle";
136 }
137 }
138 yCInfo(CouplingICubHandMk2ParamsCOMPONENT) << "Parameter 'LIMITS::jntPosMax' using value:" << m_LIMITS_jntPosMax;
139 }
140 else
141 {
142 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Mandatory parameter 'LIMITS::jntPosMax' not found!";
143 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Description of the parameter: Physical joints' position maximum";
144 return false;
145 }
146 prop_check.unput("LIMITS::jntPosMax");
147 }
148
149 //Parser of parameter COUPLING::device
150 {
151 yarp::os::Bottle sectionp;
152 sectionp = config.findGroup("COUPLING");
153 if (sectionp.check("device"))
154 {
155 m_COUPLING_device = sectionp.find("device").asString();
156 yCInfo(CouplingICubHandMk2ParamsCOMPONENT) << "Parameter 'COUPLING::device' using value:" << m_COUPLING_device;
157 }
158 else
159 {
160 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Mandatory parameter 'COUPLING::device' not found!";
161 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Description of the parameter: Name of the device that handles the coupling";
162 return false;
163 }
164 prop_check.unput("COUPLING::device");
165 }
166
167 //Parser of parameter COUPLING::actuatedAxesNames
168 {
169 yarp::os::Bottle sectionp;
170 sectionp = config.findGroup("COUPLING");
171 if (sectionp.check("actuatedAxesNames"))
172 {
173 {
175 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesNames").asList();
176 if (tempBot)
177 {
178 std::string tempBots = tempBot->toString();
179 for (size_t i=0; i<tempBot->size(); i++)
180 {
181 m_COUPLING_actuatedAxesNames.push_back(tempBot->get(i).asString());
182 }
183 }
184 else
185 {
186 yCError(CouplingICubHandMk2ParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesNames' is not a properly formatted bottle";
187 }
188 }
189 yCInfo(CouplingICubHandMk2ParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesNames' using value:" << m_COUPLING_actuatedAxesNames;
190 }
191 else
192 {
193 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesNames' not found!";
194 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Description of the parameter: Names of the actuated axes";
195 return false;
196 }
197 prop_check.unput("COUPLING::actuatedAxesNames");
198 }
199
200 //Parser of parameter COUPLING::actuatedAxesPosMin
201 {
202 yarp::os::Bottle sectionp;
203 sectionp = config.findGroup("COUPLING");
204 if (sectionp.check("actuatedAxesPosMin"))
205 {
206 {
208 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesPosMin").asList();
209 if (tempBot)
210 {
211 std::string tempBots = tempBot->toString();
212 for (size_t i=0; i<tempBot->size(); i++)
213 {
214 m_COUPLING_actuatedAxesPosMin.push_back(tempBot->get(i).asFloat64());
215 }
216 }
217 else
218 {
219 yCError(CouplingICubHandMk2ParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesPosMin' is not a properly formatted bottle";
220 }
221 }
222 yCInfo(CouplingICubHandMk2ParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesPosMin' using value:" << m_COUPLING_actuatedAxesPosMin;
223 }
224 else
225 {
226 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesPosMin' not found!";
227 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Description of the parameter: Actuated axes' position minimum";
228 return false;
229 }
230 prop_check.unput("COUPLING::actuatedAxesPosMin");
231 }
232
233 //Parser of parameter COUPLING::actuatedAxesPosMax
234 {
235 yarp::os::Bottle sectionp;
236 sectionp = config.findGroup("COUPLING");
237 if (sectionp.check("actuatedAxesPosMax"))
238 {
239 {
241 yarp::os::Bottle* tempBot = sectionp.find("actuatedAxesPosMax").asList();
242 if (tempBot)
243 {
244 std::string tempBots = tempBot->toString();
245 for (size_t i=0; i<tempBot->size(); i++)
246 {
247 m_COUPLING_actuatedAxesPosMax.push_back(tempBot->get(i).asFloat64());
248 }
249 }
250 else
251 {
252 yCError(CouplingICubHandMk2ParamsCOMPONENT) <<"parameter 'COUPLING_actuatedAxesPosMax' is not a properly formatted bottle";
253 }
254 }
255 yCInfo(CouplingICubHandMk2ParamsCOMPONENT) << "Parameter 'COUPLING::actuatedAxesPosMax' using value:" << m_COUPLING_actuatedAxesPosMax;
256 }
257 else
258 {
259 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Mandatory parameter 'COUPLING::actuatedAxesPosMax' not found!";
260 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "Description of the parameter: Actuated axes' position maximum";
261 return false;
262 }
263 prop_check.unput("COUPLING::actuatedAxesPosMax");
264 }
265
266 /*
267 //This code check if the user set some parameter which are not check by the parser
268 //If the parser is set in strict mode, this will generate an error
269 if (prop_check.size() > 0)
270 {
271 bool extra_params_found = false;
272 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
273 {
274 if (m_parser_is_strict)
275 {
276 yCError(CouplingICubHandMk2ParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
277 extra_params_found = true;
278 }
279 else
280 {
281 yCWarning(CouplingICubHandMk2ParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
282 }
283 }
284
285 if (m_parser_is_strict && extra_params_found)
286 {
287 return false;
288 }
289 }
290 */
291 return true;
292}
293
294
296{
297 std::string doc;
298 doc = doc + std::string("\n=============================================\n");
299 doc = doc + std::string("This is the help for device: CouplingICubHandMk2\n");
300 doc = doc + std::string("\n");
301 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
302 doc = doc + std::string("'jointNames': Names of the physical joints\n");
303 doc = doc + std::string("'LIMITS::jntPosMin': Physical joints' position minimum\n");
304 doc = doc + std::string("'LIMITS::jntPosMax': Physical joints' position maximum\n");
305 doc = doc + std::string("'COUPLING::device': Name of the device that handles the coupling\n");
306 doc = doc + std::string("'COUPLING::actuatedAxesNames': Names of the actuated axes\n");
307 doc = doc + std::string("'COUPLING::actuatedAxesPosMin': Actuated axes' position minimum\n");
308 doc = doc + std::string("'COUPLING::actuatedAxesPosMax': Actuated axes' position maximum\n");
309 doc = doc + std::string("\n");
310 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
311 doc = doc + " yarpdev --device couplingICubHandMk2 --jointNames <mandatory_value> --LIMITS::jntPosMin <mandatory_value> --LIMITS::jntPosMax <mandatory_value> --COUPLING::device <mandatory_value> --COUPLING::actuatedAxesNames <mandatory_value> --COUPLING::actuatedAxesPosMin <mandatory_value> --COUPLING::actuatedAxesPosMax <mandatory_value>\n";
312 doc = doc + std::string("Using only mandatory params:\n");
313 doc = doc + " yarpdev --device couplingICubHandMk2 --jointNames <mandatory_value> --LIMITS::jntPosMin <mandatory_value> --LIMITS::jntPosMax <mandatory_value> --COUPLING::device <mandatory_value> --COUPLING::actuatedAxesNames <mandatory_value> --COUPLING::actuatedAxesPosMin <mandatory_value> --COUPLING::actuatedAxesPosMax <mandatory_value>\n";
314 doc = doc + std::string("=============================================\n\n"); return doc;
315}
std::string getDocumentationOfDeviceParams() const override
bool parseParams(const yarp::os::Searchable &config) override
std::vector< std::string > m_COUPLING_actuatedAxesNames
std::vector< std::string > getListOfParams() const override