YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RgbdSensor_nws_ros2_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 Jan 29 14:11:54 2026
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(RgbdSensor_nws_ros2ParamsCOMPONENT, "yarp.device.RgbdSensor_nws_ros2")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("period");
32 params.push_back("node_name");
33 params.push_back("namespace");
34 params.push_back("color_topic_name");
35 params.push_back("depth_topic_name");
36 params.push_back("force_info_synch");
37 params.push_back("depth_frame_id");
38 params.push_back("color_frame_id");
39 params.push_back("pub_status_topic");
40 return params;
41}
42
43
44bool RgbdSensor_nws_ros2_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 =="node_name")
52 {
53 paramValue = m_node_name;
54 return true;
55 }
56 if (paramName =="namespace")
57 {
58 paramValue = m_namespace;
59 return true;
60 }
61 if (paramName =="color_topic_name")
62 {
63 paramValue = m_color_topic_name;
64 return true;
65 }
66 if (paramName =="depth_topic_name")
67 {
68 paramValue = m_depth_topic_name;
69 return true;
70 }
71 if (paramName =="force_info_synch")
72 {
73 paramValue = std::to_string(m_force_info_synch);
74 return true;
75 }
76 if (paramName =="depth_frame_id")
77 {
78 paramValue = m_depth_frame_id;
79 return true;
80 }
81 if (paramName =="color_frame_id")
82 {
83 paramValue = m_color_frame_id;
84 return true;
85 }
86 if (paramName =="pub_status_topic")
87 {
88 paramValue = std::to_string(m_pub_status_topic);
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(RgbdSensor_nws_ros2ParamsCOMPONENT) << getDocumentationOfDeviceParams();
114 }
115
118 //Parser of parameter period
119 {
120 if (config.check("period"))
121 {
122 m_period = config.find("period").asFloat64();
123 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
124 }
125 else
126 {
127 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
128 }
129 prop_check.unput("period");
130 }
131
132 //Parser of parameter node_name
133 {
134 if (config.check("node_name"))
135 {
136 m_node_name = config.find("node_name").asString();
137 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'node_name' using value:" << m_node_name;
138 }
139 else
140 {
141 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'node_name' not found!";
142 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: name of the ros2 node";
143 return false;
144 }
145 prop_check.unput("node_name");
146 }
147
148 //Parser of parameter namespace
149 {
150 if (config.check("namespace"))
151 {
152 m_namespace = config.find("namespace").asString();
153 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'namespace' using value:" << m_namespace;
154 }
155 else
156 {
157 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'namespace' using DEFAULT value:" << m_namespace;
158 }
159 prop_check.unput("namespace");
160 }
161
162 //Parser of parameter color_topic_name
163 {
164 if (config.check("color_topic_name"))
165 {
166 m_color_topic_name = config.find("color_topic_name").asString();
167 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'color_topic_name' using value:" << m_color_topic_name;
168 }
169 else
170 {
171 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'color_topic_name' not found!";
172 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: ros rgb topic (it's also the base name for the rgb camera_info topic)";
173 return false;
174 }
175 prop_check.unput("color_topic_name");
176 }
177
178 //Parser of parameter depth_topic_name
179 {
180 if (config.check("depth_topic_name"))
181 {
182 m_depth_topic_name = config.find("depth_topic_name").asString();
183 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'depth_topic_name' using value:" << m_depth_topic_name;
184 }
185 else
186 {
187 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'depth_topic_name' not found!";
188 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: ros depth topic (it's also the base name for the depth camera_info topic)";
189 return false;
190 }
191 prop_check.unput("depth_topic_name");
192 }
193
194 //Parser of parameter force_info_synch
195 {
196 if (config.check("force_info_synch"))
197 {
198 m_force_info_synch = config.find("force_info_synch").asInt64();
199 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'force_info_synch' using value:" << m_force_info_synch;
200 }
201 else
202 {
203 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'force_info_synch' using DEFAULT value:" << m_force_info_synch;
204 }
205 prop_check.unput("force_info_synch");
206 }
207
208 //Parser of parameter depth_frame_id
209 {
210 if (config.check("depth_frame_id"))
211 {
212 m_depth_frame_id = config.find("depth_frame_id").asString();
213 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'depth_frame_id' using value:" << m_depth_frame_id;
214 }
215 else
216 {
217 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'depth_frame_id' not found!";
218 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The depth image frame";
219 return false;
220 }
221 prop_check.unput("depth_frame_id");
222 }
223
224 //Parser of parameter color_frame_id
225 {
226 if (config.check("color_frame_id"))
227 {
228 m_color_frame_id = config.find("color_frame_id").asString();
229 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'color_frame_id' using value:" << m_color_frame_id;
230 }
231 else
232 {
233 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'color_frame_id' not found!";
234 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The color image frame";
235 return false;
236 }
237 prop_check.unput("color_frame_id");
238 }
239
240 //Parser of parameter pub_status_topic
241 {
242 if (config.check("pub_status_topic"))
243 {
244 m_pub_status_topic = config.find("pub_status_topic").asInt64();
245 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'pub_status_topic' using value:" << m_pub_status_topic;
246 }
247 else
248 {
249 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'pub_status_topic' using DEFAULT value:" << m_pub_status_topic;
250 }
251 prop_check.unput("pub_status_topic");
252 }
253
254 /*
255 //This code check if the user set some parameter which are not check by the parser
256 //If the parser is set in strict mode, this will generate an error
257 if (prop_check.size() > 0)
258 {
259 bool extra_params_found = false;
260 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
261 {
262 if (m_parser_is_strict)
263 {
264 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
265 extra_params_found = true;
266 }
267 else
268 {
269 yCWarning(RgbdSensor_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
270 }
271 }
272
273 if (m_parser_is_strict && extra_params_found)
274 {
275 return false;
276 }
277 }
278 */
279 return true;
280}
281
282
284{
285 std::string doc;
286 doc = doc + std::string("\n=============================================\n");
287 doc = doc + std::string("This is the help for device: RgbdSensor_nws_ros2\n");
288 doc = doc + std::string("\n");
289 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
290 doc = doc + std::string("'period': refresh period of the broadcasted values in s\n");
291 doc = doc + std::string("'node_name': name of the ros2 node\n");
292 doc = doc + std::string("'namespace': optional namespace for ros2 node\n");
293 doc = doc + std::string("'color_topic_name': ros rgb topic (it's also the base name for the rgb camera_info topic)\n");
294 doc = doc + std::string("'depth_topic_name': ros depth topic (it's also the base name for the depth camera_info topic)\n");
295 doc = doc + std::string("'force_info_synch': if 1, it forces synching images time stamp with and cameras time stamp\n");
296 doc = doc + std::string("'depth_frame_id': The depth image frame\n");
297 doc = doc + std::string("'color_frame_id': The color image frame\n");
298 doc = doc + std::string("'pub_status_topic': If 1 a topic publishing 0 if no image has been published on ros2 topic, 1 if only the RGB image is bein published, 2 for only the depth image, and 3 for both images will be opened\n");
299 doc = doc + std::string("\n");
300 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
301 doc = doc + " yarpdev --device rgbdSensor_nws_ros2 --period 0.02 --node_name <mandatory_value> --namespace <optional_value> --color_topic_name <mandatory_value> --depth_topic_name <mandatory_value> --force_info_synch 0 --depth_frame_id <mandatory_value> --color_frame_id <mandatory_value> --pub_status_topic 0\n";
302 doc = doc + std::string("Using only mandatory params:\n");
303 doc = doc + " yarpdev --device rgbdSensor_nws_ros2 --node_name <mandatory_value> --color_topic_name <mandatory_value> --depth_topic_name <mandatory_value> --depth_frame_id <mandatory_value> --color_frame_id <mandatory_value>\n";
304 doc = doc + std::string("=============================================\n\n"); return doc;
305}
#define yError(...)
Definition Log.h:361
std::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
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.
std::string getConfiguration() const override
Return the configuration of the device.
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,...)