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: Mon May 26 22:00:40 2025
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("color_topic_name");
34 params.push_back("depth_topic_name");
35 params.push_back("force_info_synch");
36 params.push_back("depth_frame_id");
37 params.push_back("color_frame_id");
38 return params;
39}
40
41
42bool RgbdSensor_nws_ros2_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
43{
44 if (paramName =="period")
45 {
46 paramValue = std::to_string(m_period);
47 return true;
48 }
49 if (paramName =="node_name")
50 {
51 paramValue = m_node_name;
52 return true;
53 }
54 if (paramName =="color_topic_name")
55 {
56 paramValue = m_color_topic_name;
57 return true;
58 }
59 if (paramName =="depth_topic_name")
60 {
61 paramValue = m_depth_topic_name;
62 return true;
63 }
64 if (paramName =="force_info_synch")
65 {
66 paramValue = std::to_string(m_force_info_synch);
67 return true;
68 }
69 if (paramName =="depth_frame_id")
70 {
71 paramValue = m_depth_frame_id;
72 return true;
73 }
74 if (paramName =="color_frame_id")
75 {
76 paramValue = m_color_frame_id;
77 return true;
78 }
79
80 yError() <<"parameter '" << paramName << "' was not found";
81 return false;
82
83}
84
85
87{
88 //This is a sub-optimal solution.
89 //Ideally getConfiguration() should return all parameters but it is currently
90 //returning only user provided parameters (excluding default values)
91 //This behaviour will be fixed in the near future.
92 std::string s_cfg = m_provided_configuration;
93 return s_cfg;
94}
95
97{
98 //Check for --help option
99 if (config.check("help"))
100 {
101 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << getDocumentationOfDeviceParams();
102 }
103
106 //Parser of parameter period
107 {
108 if (config.check("period"))
109 {
110 m_period = config.find("period").asFloat64();
111 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
112 }
113 else
114 {
115 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
116 }
117 prop_check.unput("period");
118 }
119
120 //Parser of parameter node_name
121 {
122 if (config.check("node_name"))
123 {
124 m_node_name = config.find("node_name").asString();
125 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'node_name' using value:" << m_node_name;
126 }
127 else
128 {
129 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'node_name' not found!";
130 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: name of the ros2 node";
131 return false;
132 }
133 prop_check.unput("node_name");
134 }
135
136 //Parser of parameter color_topic_name
137 {
138 if (config.check("color_topic_name"))
139 {
140 m_color_topic_name = config.find("color_topic_name").asString();
141 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'color_topic_name' using value:" << m_color_topic_name;
142 }
143 else
144 {
145 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'color_topic_name' not found!";
146 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: ros rgb topic (it's also the base name for the rgb camera_info topic)";
147 return false;
148 }
149 prop_check.unput("color_topic_name");
150 }
151
152 //Parser of parameter depth_topic_name
153 {
154 if (config.check("depth_topic_name"))
155 {
156 m_depth_topic_name = config.find("depth_topic_name").asString();
157 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'depth_topic_name' using value:" << m_depth_topic_name;
158 }
159 else
160 {
161 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'depth_topic_name' not found!";
162 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: ros depth topic (it's also the base name for the depth camera_info topic)";
163 return false;
164 }
165 prop_check.unput("depth_topic_name");
166 }
167
168 //Parser of parameter force_info_synch
169 {
170 if (config.check("force_info_synch"))
171 {
172 m_force_info_synch = config.find("force_info_synch").asInt64();
173 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'force_info_synch' using value:" << m_force_info_synch;
174 }
175 else
176 {
177 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'force_info_synch' using DEFAULT value:" << m_force_info_synch;
178 }
179 prop_check.unput("force_info_synch");
180 }
181
182 //Parser of parameter depth_frame_id
183 {
184 if (config.check("depth_frame_id"))
185 {
186 m_depth_frame_id = config.find("depth_frame_id").asString();
187 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'depth_frame_id' using value:" << m_depth_frame_id;
188 }
189 else
190 {
191 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'depth_frame_id' not found!";
192 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The depth image frame";
193 return false;
194 }
195 prop_check.unput("depth_frame_id");
196 }
197
198 //Parser of parameter color_frame_id
199 {
200 if (config.check("color_frame_id"))
201 {
202 m_color_frame_id = config.find("color_frame_id").asString();
203 yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'color_frame_id' using value:" << m_color_frame_id;
204 }
205 else
206 {
207 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'color_frame_id' not found!";
208 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The color image frame";
209 return false;
210 }
211 prop_check.unput("color_frame_id");
212 }
213
214 /*
215 //This code check if the user set some parameter which are not check by the parser
216 //If the parser is set in strict mode, this will generate an error
217 if (prop_check.size() > 0)
218 {
219 bool extra_params_found = false;
220 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
221 {
222 if (m_parser_is_strict)
223 {
224 yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
225 extra_params_found = true;
226 }
227 else
228 {
229 yCWarning(RgbdSensor_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
230 }
231 }
232
233 if (m_parser_is_strict && extra_params_found)
234 {
235 return false;
236 }
237 }
238 */
239 return true;
240}
241
242
244{
245 std::string doc;
246 doc = doc + std::string("\n=============================================\n");
247 doc = doc + std::string("This is the help for device: RgbdSensor_nws_ros2\n");
248 doc = doc + std::string("\n");
249 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
250 doc = doc + std::string("'period': refresh period of the broadcasted values in s\n");
251 doc = doc + std::string("'node_name': name of the ros2 node\n");
252 doc = doc + std::string("'color_topic_name': ros rgb topic (it's also the base name for the rgb camera_info topic)\n");
253 doc = doc + std::string("'depth_topic_name': ros depth topic (it's also the base name for the depth camera_info topic)\n");
254 doc = doc + std::string("'force_info_synch': if 1, it forces synching images time stamp with and cameras time stamp\n");
255 doc = doc + std::string("'depth_frame_id': The depth image frame\n");
256 doc = doc + std::string("'color_frame_id': The color image frame\n");
257 doc = doc + std::string("\n");
258 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
259 doc = doc + " yarpdev --device rgbdSensor_nws_ros2 --period 0.02 --node_name <mandatory_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>\n";
260 doc = doc + std::string("Using only mandatory params:\n");
261 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";
262 doc = doc + std::string("=============================================\n\n"); return doc;
263}
#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,...)