YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakeLaserWithMotor_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: Thu Mar 7 17:59:42 2024
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(FakeLaserWithMotorParamsCOMPONENT, "yarp.device.FakeLaserWithMotor")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("test");
32 params.push_back("localization_port");
33 params.push_back("localization_server");
34 params.push_back("localization_client");
35 params.push_back("localization_device");
36 params.push_back("MAP_MODE::map_file");
37 params.push_back("MAP_MODE::map_context");
38 params.push_back("clip_max");
39 params.push_back("clip_min");
40 params.push_back("GENERAL::period");
41 params.push_back("CONSTANT_MODE::const_distance");
42 return params;
43}
44
45
47{
48 //Check for --help option
49 if (config.check("help"))
50 {
51 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << getDocumentationOfDeviceParams();
52 }
53
54 std::string config_string = config.toString();
55 yarp::os::Property prop_check(config_string.c_str());
56 //Parser of parameter test
57 {
58 if (config.check("test"))
59 {
60 m_test = config.find("test").asString();
61 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'test' using value:" << m_test;
62 }
63 else
64 {
65 yCError(FakeLaserWithMotorParamsCOMPONENT) << "Mandatory parameter 'test' not found!";
66 yCError(FakeLaserWithMotorParamsCOMPONENT) << "Description of the parameter: Choose the modality";
67 return false;
68 }
69 prop_check.unput("test");
70 }
71
72 //Parser of parameter localization_port
73 {
74 if (config.check("localization_port"))
75 {
76 m_localization_port = config.find("localization_port").asString();
77 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'localization_port' using value:" << m_localization_port;
78 }
79 else
80 {
81 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'localization_port' using DEFAULT value:" << m_localization_port;
82 }
83 prop_check.unput("localization_port");
84 }
85
86 //Parser of parameter localization_server
87 {
88 if (config.check("localization_server"))
89 {
90 m_localization_server = config.find("localization_server").asString();
91 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'localization_server' using value:" << m_localization_server;
92 }
93 else
94 {
95 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'localization_server' using DEFAULT value:" << m_localization_server;
96 }
97 prop_check.unput("localization_server");
98 }
99
100 //Parser of parameter localization_client
101 {
102 if (config.check("localization_client"))
103 {
104 m_localization_client = config.find("localization_client").asString();
105 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'localization_client' using value:" << m_localization_client;
106 }
107 else
108 {
109 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'localization_client' using DEFAULT value:" << m_localization_client;
110 }
111 prop_check.unput("localization_client");
112 }
113
114 //Parser of parameter localization_device
115 {
116 if (config.check("localization_device"))
117 {
118 m_localization_device = config.find("localization_device").asString();
119 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'localization_device' using value:" << m_localization_device;
120 }
121 else
122 {
123 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'localization_device' using DEFAULT value:" << m_localization_device;
124 }
125 prop_check.unput("localization_device");
126 }
127
128 //Parser of parameter MAP_MODE::map_file
129 {
130 yarp::os::Bottle sectionp;
131 sectionp = config.findGroup("MAP_MODE");
132 if (sectionp.check("map_file"))
133 {
134 m_MAP_MODE_map_file = sectionp.find("map_file").asString();
135 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'MAP_MODE::map_file' using value:" << m_MAP_MODE_map_file;
136 }
137 else
138 {
139 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'MAP_MODE::map_file' using DEFAULT value:" << m_MAP_MODE_map_file;
140 }
141 prop_check.unput("MAP_MODE::map_file");
142 }
143
144 //Parser of parameter MAP_MODE::map_context
145 {
146 yarp::os::Bottle sectionp;
147 sectionp = config.findGroup("MAP_MODE");
148 if (sectionp.check("map_context"))
149 {
150 m_MAP_MODE_map_context = sectionp.find("map_context").asString();
151 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'MAP_MODE::map_context' using value:" << m_MAP_MODE_map_context;
152 }
153 else
154 {
155 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'MAP_MODE::map_context' using DEFAULT value:" << m_MAP_MODE_map_context;
156 }
157 prop_check.unput("MAP_MODE::map_context");
158 }
159
160 //Parser of parameter clip_max
161 {
162 if (config.check("clip_max"))
163 {
164 m_clip_max = config.find("clip_max").asFloat64();
165 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'clip_max' using value:" << m_clip_max;
166 }
167 else
168 {
169 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'clip_max' using DEFAULT value:" << m_clip_max;
170 }
171 prop_check.unput("clip_max");
172 }
173
174 //Parser of parameter clip_min
175 {
176 if (config.check("clip_min"))
177 {
178 m_clip_min = config.find("clip_min").asFloat64();
179 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'clip_min' using value:" << m_clip_min;
180 }
181 else
182 {
183 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'clip_min' using DEFAULT value:" << m_clip_min;
184 }
185 prop_check.unput("clip_min");
186 }
187
188 //Parser of parameter GENERAL::period
189 {
190 yarp::os::Bottle sectionp;
191 sectionp = config.findGroup("GENERAL");
192 if (sectionp.check("period"))
193 {
194 m_GENERAL_period = sectionp.find("period").asFloat64();
195 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'GENERAL::period' using value:" << m_GENERAL_period;
196 }
197 else
198 {
199 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'GENERAL::period' using DEFAULT value:" << m_GENERAL_period;
200 }
201 prop_check.unput("GENERAL::period");
202 }
203
204 //Parser of parameter CONSTANT_MODE::const_distance
205 {
206 yarp::os::Bottle sectionp;
207 sectionp = config.findGroup("CONSTANT_MODE");
208 if (sectionp.check("const_distance"))
209 {
210 m_CONSTANT_MODE_const_distance = sectionp.find("const_distance").asFloat64();
211 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'CONSTANT_MODE::const_distance' using value:" << m_CONSTANT_MODE_const_distance;
212 }
213 else
214 {
215 yCInfo(FakeLaserWithMotorParamsCOMPONENT) << "Parameter 'CONSTANT_MODE::const_distance' using DEFAULT value:" << m_CONSTANT_MODE_const_distance;
216 }
217 prop_check.unput("CONSTANT_MODE::const_distance");
218 }
219
220 /*
221 //This code check if the user set some parameter which are not check by the parser
222 //If the parser is set in strict mode, this will generate an error
223 if (prop_check.size() > 0)
224 {
225 bool extra_params_found = false;
226 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
227 {
228 if (m_parser_is_strict)
229 {
230 yCError(FakeLaserWithMotorParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
231 extra_params_found = true;
232 }
233 else
234 {
235 yCWarning(FakeLaserWithMotorParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
236 }
237 }
238
239 if (m_parser_is_strict && extra_params_found)
240 {
241 return false;
242 }
243 }
244 */
245 return true;
246}
247
248
250{
251 std::string doc;
252 doc = doc + std::string("\n=============================================\n");
253 doc = doc + std::string("This is the help for device: FakeLaserWithMotor\n");
254 doc = doc + std::string("\n");
255 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
256 doc = doc + std::string("'test': Choose the modality\n");
257 doc = doc + std::string("'localization_port': Full name of the port to which device connects to receive the localization data\n");
258 doc = doc + std::string("'localization_server': Full name of the port to which device connects to receive the localization data\n");
259 doc = doc + std::string("'localization_client': Full name of the local transformClient opened by the device\n");
260 doc = doc + std::string("'localization_device': Type of localization device, e.g. localization2DClient, localization2D_nwc_yarp\n");
261 doc = doc + std::string("'MAP_MODE::map_file': Full path to a .map file\n");
262 doc = doc + std::string("'MAP_MODE::map_context': Full path to a .map file\n");
263 doc = doc + std::string("'clip_max': Maximum detectable distance for an obstacle\n");
264 doc = doc + std::string("'clip_min': Minimum detectable distance for an obstacle\n");
265 doc = doc + std::string("'GENERAL::period': Thread period\n");
266 doc = doc + std::string("'CONSTANT_MODE::const_distance': Default const distance for mode use_constant\n");
267 doc = doc + std::string("\n");
268 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
269 doc = doc + " yarpdev --device fakeLaserWithMotor --test use_pattern --localization_port /fakeLaser/location:i --localization_server /localizationServer --localization_client /fakeLaser/localizationClient --localization_device localization2DClient --MAP_MODE::map_file <optional_value> --MAP_MODE::map_context <optional_value> --clip_max 3.5 --clip_min 0.1 --GENERAL::period 0.02 --CONSTANT_MODE::const_distance 1\n";
270 doc = doc + std::string("Using only mandatory params:\n");
271 doc = doc + " yarpdev --device fakeLaserWithMotor --test use_pattern\n";
272 doc = doc + std::string("=============================================\n\n"); return doc;
273}
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition Bottle.cpp:277
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 Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition Value.cpp:222
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)