YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeMotionControlMicro_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:17 2026
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(FakeMotionControlMicroParamsCOMPONENT, "yarp.device.FakeMotionControlMicro")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("GENERAL::Joints");
32 params.push_back("GENERAL::AxisMap");
33 params.push_back("GENERAL::AxisName");
34 params.push_back("GENERAL::AxisType");
35 params.push_back("GENERAL::Encoder");
36 return params;
37}
38
39
40bool FakeMotionControlMicro_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
41{
42 if (paramName =="GENERAL::Joints")
43 {
44 paramValue = std::to_string(m_GENERAL_Joints);
45 return true;
46 }
47 if (paramName =="GENERAL::AxisMap")
48 {
49 std::ostringstream oss;
50 oss << "( ";
51 for (auto x : m_GENERAL_AxisMap)
52 {
53 oss << x << " ";
54 }
55 oss << " )";
56 paramValue = oss.str();
57 return true;
58 }
59 if (paramName =="GENERAL::AxisName")
60 {
61 std::ostringstream oss;
62 oss << "( ";
63 for (auto x : m_GENERAL_AxisName)
64 {
65 oss << x << " ";
66 }
67 oss << " )";
68 paramValue = oss.str();
69 return true;
70 }
71 if (paramName =="GENERAL::AxisType")
72 {
73 std::ostringstream oss;
74 oss << "( ";
75 for (auto x : m_GENERAL_AxisType)
76 {
77 oss << x << " ";
78 }
79 oss << " )";
80 paramValue = oss.str();
81 return true;
82 }
83 if (paramName =="GENERAL::Encoder")
84 {
85 std::ostringstream oss;
86 oss << "( ";
87 for (auto x : m_GENERAL_Encoder)
88 {
89 oss << x << " ";
90 }
91 oss << " )";
92 paramValue = oss.str();
93 return true;
94 }
95
96 yError() <<"parameter '" << paramName << "' was not found";
97 return false;
98
99}
100
101
103{
104 //This is a sub-optimal solution.
105 //Ideally getConfiguration() should return all parameters but it is currently
106 //returning only user provided parameters (excluding default values)
107 //This behaviour will be fixed in the near future.
108 std::string s_cfg = m_provided_configuration;
109 return s_cfg;
110}
111
113{
114 //Check for --help option
115 if (config.check("help"))
116 {
117 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << getDocumentationOfDeviceParams();
118 }
119
122 //Parser of parameter GENERAL::Joints
123 {
124 yarp::os::Bottle sectionp;
125 sectionp = config.findGroup("GENERAL");
126 if (sectionp.check("Joints"))
127 {
128 m_GENERAL_Joints = sectionp.find("Joints").asInt64();
129 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::Joints' using value:" << m_GENERAL_Joints;
130 }
131 else
132 {
133 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::Joints' using DEFAULT value:" << m_GENERAL_Joints;
134 }
135 prop_check.unput("GENERAL::Joints");
136 }
137
138 //Parser of parameter GENERAL::AxisMap
139 {
140 yarp::os::Bottle sectionp;
141 sectionp = config.findGroup("GENERAL");
142 if (sectionp.check("AxisMap"))
143 {
144 {
145 m_GENERAL_AxisMap.clear();
146 yarp::os::Bottle* tempBot = sectionp.find("AxisMap").asList();
147 if (tempBot)
148 {
149 std::string tempBots = tempBot->toString();
150 for (size_t i=0; i<tempBot->size(); i++)
151 {
152 m_GENERAL_AxisMap.push_back(tempBot->get(i).asInt64());
153 }
154 }
155 else
156 {
157 yCError(FakeMotionControlMicroParamsCOMPONENT) <<"parameter 'GENERAL_AxisMap' is not a properly formatted bottle";
158 }
159 }
160 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisMap' using value:" << m_GENERAL_AxisMap;
161 }
162 else
163 {
164 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisMap' using DEFAULT value:" << m_GENERAL_AxisMap;
165 }
166 prop_check.unput("GENERAL::AxisMap");
167 }
168
169 //Parser of parameter GENERAL::AxisName
170 {
171 yarp::os::Bottle sectionp;
172 sectionp = config.findGroup("GENERAL");
173 if (sectionp.check("AxisName"))
174 {
175 {
176 m_GENERAL_AxisName.clear();
177 yarp::os::Bottle* tempBot = sectionp.find("AxisName").asList();
178 if (tempBot)
179 {
180 std::string tempBots = tempBot->toString();
181 for (size_t i=0; i<tempBot->size(); i++)
182 {
183 m_GENERAL_AxisName.push_back(tempBot->get(i).asString());
184 }
185 }
186 else
187 {
188 yCError(FakeMotionControlMicroParamsCOMPONENT) <<"parameter 'GENERAL_AxisName' is not a properly formatted bottle";
189 }
190 }
191 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisName' using value:" << m_GENERAL_AxisName;
192 }
193 else
194 {
195 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisName' using DEFAULT value:" << m_GENERAL_AxisName;
196 }
197 prop_check.unput("GENERAL::AxisName");
198 }
199
200 //Parser of parameter GENERAL::AxisType
201 {
202 yarp::os::Bottle sectionp;
203 sectionp = config.findGroup("GENERAL");
204 if (sectionp.check("AxisType"))
205 {
206 {
207 m_GENERAL_AxisType.clear();
208 yarp::os::Bottle* tempBot = sectionp.find("AxisType").asList();
209 if (tempBot)
210 {
211 std::string tempBots = tempBot->toString();
212 for (size_t i=0; i<tempBot->size(); i++)
213 {
214 m_GENERAL_AxisType.push_back(tempBot->get(i).asString());
215 }
216 }
217 else
218 {
219 yCError(FakeMotionControlMicroParamsCOMPONENT) <<"parameter 'GENERAL_AxisType' is not a properly formatted bottle";
220 }
221 }
222 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisType' using value:" << m_GENERAL_AxisType;
223 }
224 else
225 {
226 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisType' using DEFAULT value:" << m_GENERAL_AxisType;
227 }
228 prop_check.unput("GENERAL::AxisType");
229 }
230
231 //Parser of parameter GENERAL::Encoder
232 {
233 yarp::os::Bottle sectionp;
234 sectionp = config.findGroup("GENERAL");
235 if (sectionp.check("Encoder"))
236 {
237 {
238 m_GENERAL_Encoder.clear();
239 yarp::os::Bottle* tempBot = sectionp.find("Encoder").asList();
240 if (tempBot)
241 {
242 std::string tempBots = tempBot->toString();
243 for (size_t i=0; i<tempBot->size(); i++)
244 {
245 m_GENERAL_Encoder.push_back(tempBot->get(i).asInt64());
246 }
247 }
248 else
249 {
250 yCError(FakeMotionControlMicroParamsCOMPONENT) <<"parameter 'GENERAL_Encoder' is not a properly formatted bottle";
251 }
252 }
253 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::Encoder' using value:" << m_GENERAL_Encoder;
254 }
255 else
256 {
257 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::Encoder' using DEFAULT value:" << m_GENERAL_Encoder;
258 }
259 prop_check.unput("GENERAL::Encoder");
260 }
261
262 /*
263 //This code check if the user set some parameter which are not check by the parser
264 //If the parser is set in strict mode, this will generate an error
265 if (prop_check.size() > 0)
266 {
267 bool extra_params_found = false;
268 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
269 {
270 if (m_parser_is_strict)
271 {
272 yCError(FakeMotionControlMicroParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
273 extra_params_found = true;
274 }
275 else
276 {
277 yCWarning(FakeMotionControlMicroParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
278 }
279 }
280
281 if (m_parser_is_strict && extra_params_found)
282 {
283 return false;
284 }
285 }
286 */
287 return true;
288}
289
290
292{
293 std::string doc;
294 doc = doc + std::string("\n=============================================\n");
295 doc = doc + std::string("This is the help for device: FakeMotionControlMicro\n");
296 doc = doc + std::string("\n");
297 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
298 doc = doc + std::string("'GENERAL::Joints': Number of degrees of freedom\n");
299 doc = doc + std::string("'GENERAL::AxisMap': a list of reordered indices for the axes\n");
300 doc = doc + std::string("'GENERAL::AxisName': a list of strings representing the axes names\n");
301 doc = doc + std::string("'GENERAL::AxisType': a list of strings representing the axes type (revolute/prismatic)\n");
302 doc = doc + std::string("'GENERAL::Encoder': a list of scales for the encoders\n");
303 doc = doc + std::string("\n");
304 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
305 doc = doc + " yarpdev --device fakeMotionControlMicro --GENERAL::Joints 1 --GENERAL::AxisMap <optional_value> --GENERAL::AxisName <optional_value> --GENERAL::AxisType <optional_value> --GENERAL::Encoder <optional_value>\n";
306 doc = doc + std::string("Using only mandatory params:\n");
307 doc = doc + " yarpdev --device fakeMotionControlMicro\n";
308 doc = doc + std::string("=============================================\n\n"); return doc;
309}
#define yError(...)
Definition Log.h:361
std::string getConfiguration() const override
Return the configuration of the device.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
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.
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
size_type size() const
Gets the number of elements in the bottle.
Definition Bottle.cpp:257
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:252
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition Bottle.cpp:283
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:217
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 Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
virtual std::int64_t asInt64() const
Get 64-bit integer value.
Definition Value.cpp:216
virtual Bottle * asList() const
Get list value.
Definition Value.cpp:252
virtual std::string asString() const
Get string value.
Definition Value.cpp:246
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)