YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RGBDSensorClient_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:44 2025
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(RGBDSensorClientParamsCOMPONENT, "yarp.device.RGBDSensorClient")
20}
21
22
26
27
28std::vector<std::string> RGBDSensorClient_ParamsParser::getListOfParams() const
29{
30 std::vector<std::string> params;
31 params.push_back("period");
32 params.push_back("localImagePort");
33 params.push_back("localDepthPort");
34 params.push_back("remoteImagePort");
35 params.push_back("remoteDepthPort");
36 params.push_back("localRpcPort");
37 params.push_back("remoteRpcPort");
38 params.push_back("ImageCarrier");
39 params.push_back("DepthCarrier");
40 return params;
41}
42
43
44bool RGBDSensorClient_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
45{
46 if (paramName =="period")
47 {
48 paramValue = std::to_string(m_period);
49 return true;
50 }
51 if (paramName =="localImagePort")
52 {
53 paramValue = m_localImagePort;
54 return true;
55 }
56 if (paramName =="localDepthPort")
57 {
58 paramValue = m_localDepthPort;
59 return true;
60 }
61 if (paramName =="remoteImagePort")
62 {
63 paramValue = m_remoteImagePort;
64 return true;
65 }
66 if (paramName =="remoteDepthPort")
67 {
68 paramValue = m_remoteDepthPort;
69 return true;
70 }
71 if (paramName =="localRpcPort")
72 {
73 paramValue = m_localRpcPort;
74 return true;
75 }
76 if (paramName =="remoteRpcPort")
77 {
78 paramValue = m_remoteRpcPort;
79 return true;
80 }
81 if (paramName =="ImageCarrier")
82 {
83 paramValue = m_ImageCarrier;
84 return true;
85 }
86 if (paramName =="DepthCarrier")
87 {
88 paramValue = m_DepthCarrier;
89 return true;
90 }
91
92 yError() <<"parameter '" << paramName << "' was not found";
93 return false;
94
95}
96
97
99{
100 //This is a sub-optimal solution.
101 //Ideally getConfiguration() should return all parameters but it is currently
102 //returning only user provided parameters (excluding default values)
103 //This behaviour will be fixed in the near future.
104 std::string s_cfg = m_provided_configuration;
105 return s_cfg;
106}
107
109{
110 //Check for --help option
111 if (config.check("help"))
112 {
113 yCInfo(RGBDSensorClientParamsCOMPONENT) << getDocumentationOfDeviceParams();
114 }
115
118 //Parser of parameter period
119 {
120 if (config.check("period"))
121 {
122 m_period = config.find("period").asFloat64();
123 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
124 }
125 else
126 {
127 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
128 }
129 prop_check.unput("period");
130 }
131
132 //Parser of parameter localImagePort
133 {
134 if (config.check("localImagePort"))
135 {
136 m_localImagePort = config.find("localImagePort").asString();
137 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'localImagePort' using value:" << m_localImagePort;
138 }
139 else
140 {
141 yCError(RGBDSensorClientParamsCOMPONENT) << "Mandatory parameter 'localImagePort' not found!";
142 yCError(RGBDSensorClientParamsCOMPONENT) << "Description of the parameter: Full name of the local image streaming port to open";
143 return false;
144 }
145 prop_check.unput("localImagePort");
146 }
147
148 //Parser of parameter localDepthPort
149 {
150 if (config.check("localDepthPort"))
151 {
152 m_localDepthPort = config.find("localDepthPort").asString();
153 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'localDepthPort' using value:" << m_localDepthPort;
154 }
155 else
156 {
157 yCError(RGBDSensorClientParamsCOMPONENT) << "Mandatory parameter 'localDepthPort' not found!";
158 yCError(RGBDSensorClientParamsCOMPONENT) << "Description of the parameter: Full name of the local depth streaming port to open";
159 return false;
160 }
161 prop_check.unput("localDepthPort");
162 }
163
164 //Parser of parameter remoteImagePort
165 {
166 if (config.check("remoteImagePort"))
167 {
168 m_remoteImagePort = config.find("remoteImagePort").asString();
169 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'remoteImagePort' using value:" << m_remoteImagePort;
170 }
171 else
172 {
173 yCError(RGBDSensorClientParamsCOMPONENT) << "Mandatory parameter 'remoteImagePort' not found!";
174 yCError(RGBDSensorClientParamsCOMPONENT) << "Description of the parameter: Full name of the remote image port to connect to";
175 return false;
176 }
177 prop_check.unput("remoteImagePort");
178 }
179
180 //Parser of parameter remoteDepthPort
181 {
182 if (config.check("remoteDepthPort"))
183 {
184 m_remoteDepthPort = config.find("remoteDepthPort").asString();
185 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'remoteDepthPort' using value:" << m_remoteDepthPort;
186 }
187 else
188 {
189 yCError(RGBDSensorClientParamsCOMPONENT) << "Mandatory parameter 'remoteDepthPort' not found!";
190 yCError(RGBDSensorClientParamsCOMPONENT) << "Description of the parameter: Full name of the remote depth port to connect to";
191 return false;
192 }
193 prop_check.unput("remoteDepthPort");
194 }
195
196 //Parser of parameter localRpcPort
197 {
198 if (config.check("localRpcPort"))
199 {
200 m_localRpcPort = config.find("localRpcPort").asString();
201 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'localRpcPort' using value:" << m_localRpcPort;
202 }
203 else
204 {
205 yCError(RGBDSensorClientParamsCOMPONENT) << "Mandatory parameter 'localRpcPort' not found!";
206 yCError(RGBDSensorClientParamsCOMPONENT) << "Description of the parameter: Full name of the local rpc port to open";
207 return false;
208 }
209 prop_check.unput("localRpcPort");
210 }
211
212 //Parser of parameter remoteRpcPort
213 {
214 if (config.check("remoteRpcPort"))
215 {
216 m_remoteRpcPort = config.find("remoteRpcPort").asString();
217 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'remoteRpcPort' using value:" << m_remoteRpcPort;
218 }
219 else
220 {
221 yCError(RGBDSensorClientParamsCOMPONENT) << "Mandatory parameter 'remoteRpcPort' not found!";
222 yCError(RGBDSensorClientParamsCOMPONENT) << "Description of the parameter: Full name of the remote rpc port to connect to";
223 return false;
224 }
225 prop_check.unput("remoteRpcPort");
226 }
227
228 //Parser of parameter ImageCarrier
229 {
230 if (config.check("ImageCarrier"))
231 {
232 m_ImageCarrier = config.find("ImageCarrier").asString();
233 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'ImageCarrier' using value:" << m_ImageCarrier;
234 }
235 else
236 {
237 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'ImageCarrier' using DEFAULT value:" << m_ImageCarrier;
238 }
239 prop_check.unput("ImageCarrier");
240 }
241
242 //Parser of parameter DepthCarrier
243 {
244 if (config.check("DepthCarrier"))
245 {
246 m_DepthCarrier = config.find("DepthCarrier").asString();
247 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'DepthCarrier' using value:" << m_DepthCarrier;
248 }
249 else
250 {
251 yCInfo(RGBDSensorClientParamsCOMPONENT) << "Parameter 'DepthCarrier' using DEFAULT value:" << m_DepthCarrier;
252 }
253 prop_check.unput("DepthCarrier");
254 }
255
256 /*
257 //This code check if the user set some parameter which are not check by the parser
258 //If the parser is set in strict mode, this will generate an error
259 if (prop_check.size() > 0)
260 {
261 bool extra_params_found = false;
262 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
263 {
264 if (m_parser_is_strict)
265 {
266 yCError(RGBDSensorClientParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
267 extra_params_found = true;
268 }
269 else
270 {
271 yCWarning(RGBDSensorClientParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
272 }
273 }
274
275 if (m_parser_is_strict && extra_params_found)
276 {
277 return false;
278 }
279 }
280 */
281 return true;
282}
283
284
286{
287 std::string doc;
288 doc = doc + std::string("\n=============================================\n");
289 doc = doc + std::string("This is the help for device: RGBDSensorClient\n");
290 doc = doc + std::string("\n");
291 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
292 doc = doc + std::string("'period': refresh period (in s) of the broadcasted values through yarp ports\n");
293 doc = doc + std::string("'localImagePort': Full name of the local image streaming port to open\n");
294 doc = doc + std::string("'localDepthPort': Full name of the local depth streaming port to open\n");
295 doc = doc + std::string("'remoteImagePort': Full name of the remote image port to connect to\n");
296 doc = doc + std::string("'remoteDepthPort': Full name of the remote depth port to connect to\n");
297 doc = doc + std::string("'localRpcPort': Full name of the local rpc port to open\n");
298 doc = doc + std::string("'remoteRpcPort': Full name of the remote rpc port to connect to\n");
299 doc = doc + std::string("'ImageCarrier': Carrier for the image stream\n");
300 doc = doc + std::string("'DepthCarrier': Carrier for the depth stream\n");
301 doc = doc + std::string("\n");
302 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
303 doc = doc + " yarpdev --device RGBDSensorClient --period 0.03 --localImagePort /RGBD_nwc/Image:o --localDepthPort /RGBD_nwc/Depth:o --remoteImagePort /RGBD_nws/Image:o --remoteDepthPort /RGBD_nws/Depth:i --localRpcPort /RGBD_nwc/rpc:o --remoteRpcPort /RGBD_nws/rpc:i --ImageCarrier udp --DepthCarrier udp\n";
304 doc = doc + std::string("Using only mandatory params:\n");
305 doc = doc + " yarpdev --device RGBDSensorClient --localImagePort /RGBD_nwc/Image:o --localDepthPort /RGBD_nwc/Depth:o --remoteImagePort /RGBD_nws/Image:o --remoteDepthPort /RGBD_nws/Depth:i --localRpcPort /RGBD_nwc/rpc:o --remoteRpcPort /RGBD_nws/rpc:i\n";
306 doc = doc + std::string("=============================================\n\n"); return doc;
307}
#define yError(...)
Definition Log.h:361
std::string getConfiguration() const override
Return the configuration of the device.
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.
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 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.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)