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