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.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: Thu May 22 11:32:31 2025
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 return false;
50 }
51 if (paramName =="GENERAL::AxisName")
52 {
53 return false;
54 }
55 if (paramName =="GENERAL::AxisType")
56 {
57 return false;
58 }
59 if (paramName =="GENERAL::Encoder")
60 {
61 return false;
62 }
63
64 yError() <<"parameter '" << paramName << "' was not found";
65 return false;
66
67}
68
69
71{
72 //This is a sub-optimal solution.
73 //Ideally getConfiguration() should return all parameters but it is currently
74 //returning only user provided parameters (excluding default values)
75 //This behaviour will be fixed in the near future.
76 std::string s_cfg = m_provided_configuration;
77 return s_cfg;
78}
79
81{
82 //Check for --help option
83 if (config.check("help"))
84 {
85 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << getDocumentationOfDeviceParams();
86 }
87
90 //Parser of parameter GENERAL::Joints
91 {
92 yarp::os::Bottle sectionp;
93 sectionp = config.findGroup("GENERAL");
94 if (sectionp.check("Joints"))
95 {
96 m_GENERAL_Joints = sectionp.find("Joints").asInt64();
97 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::Joints' using value:" << m_GENERAL_Joints;
98 }
99 else
100 {
101 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::Joints' using DEFAULT value:" << m_GENERAL_Joints;
102 }
103 prop_check.unput("GENERAL::Joints");
104 }
105
106 //Parser of parameter GENERAL::AxisMap
107 {
108 yarp::os::Bottle sectionp;
109 sectionp = config.findGroup("GENERAL");
110 if (sectionp.check("AxisMap"))
111 {
112 {
113 m_GENERAL_AxisMap.clear();
114 yarp::os::Bottle* tempBot = sectionp.find("AxisMap").asList();
115 if (tempBot)
116 {
117 std::string tempBots = tempBot->toString();
118 for (size_t i=0; i<tempBot->size(); i++)
119 {
120 m_GENERAL_AxisMap.push_back(tempBot->get(i).asInt64());
121 }
122 }
123 else
124 {
125 yCError(FakeMotionControlMicroParamsCOMPONENT) <<"parameter 'GENERAL_AxisMap' is not a properly formatted bottle";
126 }
127 }
128 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisMap' using value:" << m_GENERAL_AxisMap;
129 }
130 else
131 {
132 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisMap' using DEFAULT value:" << m_GENERAL_AxisMap;
133 }
134 prop_check.unput("GENERAL::AxisMap");
135 }
136
137 //Parser of parameter GENERAL::AxisName
138 {
139 yarp::os::Bottle sectionp;
140 sectionp = config.findGroup("GENERAL");
141 if (sectionp.check("AxisName"))
142 {
143 {
144 m_GENERAL_AxisName.clear();
145 yarp::os::Bottle* tempBot = sectionp.find("AxisName").asList();
146 if (tempBot)
147 {
148 std::string tempBots = tempBot->toString();
149 for (size_t i=0; i<tempBot->size(); i++)
150 {
151 m_GENERAL_AxisName.push_back(tempBot->get(i).asString());
152 }
153 }
154 else
155 {
156 yCError(FakeMotionControlMicroParamsCOMPONENT) <<"parameter 'GENERAL_AxisName' is not a properly formatted bottle";
157 }
158 }
159 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisName' using value:" << m_GENERAL_AxisName;
160 }
161 else
162 {
163 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisName' using DEFAULT value:" << m_GENERAL_AxisName;
164 }
165 prop_check.unput("GENERAL::AxisName");
166 }
167
168 //Parser of parameter GENERAL::AxisType
169 {
170 yarp::os::Bottle sectionp;
171 sectionp = config.findGroup("GENERAL");
172 if (sectionp.check("AxisType"))
173 {
174 {
175 m_GENERAL_AxisType.clear();
176 yarp::os::Bottle* tempBot = sectionp.find("AxisType").asList();
177 if (tempBot)
178 {
179 std::string tempBots = tempBot->toString();
180 for (size_t i=0; i<tempBot->size(); i++)
181 {
182 m_GENERAL_AxisType.push_back(tempBot->get(i).asString());
183 }
184 }
185 else
186 {
187 yCError(FakeMotionControlMicroParamsCOMPONENT) <<"parameter 'GENERAL_AxisType' is not a properly formatted bottle";
188 }
189 }
190 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisType' using value:" << m_GENERAL_AxisType;
191 }
192 else
193 {
194 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::AxisType' using DEFAULT value:" << m_GENERAL_AxisType;
195 }
196 prop_check.unput("GENERAL::AxisType");
197 }
198
199 //Parser of parameter GENERAL::Encoder
200 {
201 yarp::os::Bottle sectionp;
202 sectionp = config.findGroup("GENERAL");
203 if (sectionp.check("Encoder"))
204 {
205 {
206 m_GENERAL_Encoder.clear();
207 yarp::os::Bottle* tempBot = sectionp.find("Encoder").asList();
208 if (tempBot)
209 {
210 std::string tempBots = tempBot->toString();
211 for (size_t i=0; i<tempBot->size(); i++)
212 {
213 m_GENERAL_Encoder.push_back(tempBot->get(i).asInt64());
214 }
215 }
216 else
217 {
218 yCError(FakeMotionControlMicroParamsCOMPONENT) <<"parameter 'GENERAL_Encoder' is not a properly formatted bottle";
219 }
220 }
221 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::Encoder' using value:" << m_GENERAL_Encoder;
222 }
223 else
224 {
225 yCInfo(FakeMotionControlMicroParamsCOMPONENT) << "Parameter 'GENERAL::Encoder' using DEFAULT value:" << m_GENERAL_Encoder;
226 }
227 prop_check.unput("GENERAL::Encoder");
228 }
229
230 /*
231 //This code check if the user set some parameter which are not check by the parser
232 //If the parser is set in strict mode, this will generate an error
233 if (prop_check.size() > 0)
234 {
235 bool extra_params_found = false;
236 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
237 {
238 if (m_parser_is_strict)
239 {
240 yCError(FakeMotionControlMicroParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
241 extra_params_found = true;
242 }
243 else
244 {
245 yCWarning(FakeMotionControlMicroParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
246 }
247 }
248
249 if (m_parser_is_strict && extra_params_found)
250 {
251 return false;
252 }
253 }
254 */
255 return true;
256}
257
258
260{
261 std::string doc;
262 doc = doc + std::string("\n=============================================\n");
263 doc = doc + std::string("This is the help for device: FakeMotionControlMicro\n");
264 doc = doc + std::string("\n");
265 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
266 doc = doc + std::string("'GENERAL::Joints': Number of degrees of freedom\n");
267 doc = doc + std::string("'GENERAL::AxisMap': a list of reordered indices for the axes\n");
268 doc = doc + std::string("'GENERAL::AxisName': a list of strings representing the axes names\n");
269 doc = doc + std::string("'GENERAL::AxisType': a list of strings representing the axes type (revolute/prismatic)\n");
270 doc = doc + std::string("'GENERAL::Encoder': a list of scales for the encoders\n");
271 doc = doc + std::string("\n");
272 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
273 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";
274 doc = doc + std::string("Using only mandatory params:\n");
275 doc = doc + " yarpdev --device fakeMotionControlMicro\n";
276 doc = doc + std::string("=============================================\n\n"); return doc;
277}
#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:64
size_type size() const
Gets the number of elements in the bottle.
Definition Bottle.cpp:251
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:246
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition Bottle.cpp:277
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:211
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition Bottle.cpp:287
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:210
virtual Bottle * asList() const
Get list value.
Definition Value.cpp:240
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)