YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
argusCameraDriver_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 Jun 26 16:17:20 2025
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(argusCameraDriverParamsCOMPONENT, "yarp.device.argusCameraDriver")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("d");
32 params.push_back("period");
33 params.push_back("rotation");
34 params.push_back("width");
35 params.push_back("height");
36 params.push_back("rotation_with_crop");
37 return params;
38}
39
40
41bool argusCameraDriver_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
42{
43 if (paramName =="d")
44 {
45 paramValue = std::to_string(m_d);
46 return true;
47 }
48 if (paramName =="period")
49 {
50 paramValue = std::to_string(m_period);
51 return true;
52 }
53 if (paramName =="rotation")
54 {
55 paramValue = std::to_string(m_rotation);
56 return true;
57 }
58 if (paramName =="width")
59 {
60 paramValue = std::to_string(m_width);
61 return true;
62 }
63 if (paramName =="height")
64 {
65 paramValue = std::to_string(m_height);
66 return true;
67 }
68 if (paramName =="rotation_with_crop")
69 {
70 if (m_rotation_with_crop==true) paramValue = "true";
71 else paramValue = "false";
72 return true;
73 }
74
75 yError() <<"parameter '" << paramName << "' was not found";
76 return false;
77
78}
79
80
82{
83 //This is a sub-optimal solution.
84 //Ideally getConfiguration() should return all parameters but it is currently
85 //returning only user provided parameters (excluding default values)
86 //This behaviour will be fixed in the near future.
87 std::string s_cfg = m_provided_configuration;
88 return s_cfg;
89}
90
92{
93 //Check for --help option
94 if (config.check("help"))
95 {
96 yCInfo(argusCameraDriverParamsCOMPONENT) << getDocumentationOfDeviceParams();
97 }
98
101 //Parser of parameter d
102 {
103 if (config.check("d"))
104 {
105 m_d = config.find("d").asInt64();
106 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'd' using value:" << m_d;
107 }
108 else
109 {
110 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'd' using DEFAULT value:" << m_d;
111 }
112 prop_check.unput("d");
113 }
114
115 //Parser of parameter period
116 {
117 if (config.check("period"))
118 {
119 m_period = config.find("period").asFloat64();
120 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
121 }
122 else
123 {
124 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
125 }
126 prop_check.unput("period");
127 }
128
129 //Parser of parameter rotation
130 {
131 if (config.check("rotation"))
132 {
133 m_rotation = config.find("rotation").asFloat64();
134 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'rotation' using value:" << m_rotation;
135 }
136 else
137 {
138 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'rotation' using DEFAULT value:" << m_rotation;
139 }
140 prop_check.unput("rotation");
141 }
142
143 //Parser of parameter width
144 {
145 if (config.check("width"))
146 {
147 m_width = config.find("width").asInt64();
148 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'width' using value:" << m_width;
149 }
150 else
151 {
152 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'width' using DEFAULT value:" << m_width;
153 }
154 prop_check.unput("width");
155 }
156
157 //Parser of parameter height
158 {
159 if (config.check("height"))
160 {
161 m_height = config.find("height").asInt64();
162 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'height' using value:" << m_height;
163 }
164 else
165 {
166 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'height' using DEFAULT value:" << m_height;
167 }
168 prop_check.unput("height");
169 }
170
171 //Parser of parameter rotation_with_crop
172 {
173 if (config.check("rotation_with_crop"))
174 {
175 m_rotation_with_crop = config.find("rotation_with_crop").asBool();
176 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'rotation_with_crop' using value:" << m_rotation_with_crop;
177 }
178 else
179 {
180 yCInfo(argusCameraDriverParamsCOMPONENT) << "Parameter 'rotation_with_crop' using DEFAULT value:" << m_rotation_with_crop;
181 }
182 prop_check.unput("rotation_with_crop");
183 }
184
185 /*
186 //This code check if the user set some parameter which are not check by the parser
187 //If the parser is set in strict mode, this will generate an error
188 if (prop_check.size() > 0)
189 {
190 bool extra_params_found = false;
191 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
192 {
193 if (m_parser_is_strict)
194 {
195 yCError(argusCameraDriverParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
196 extra_params_found = true;
197 }
198 else
199 {
200 yCWarning(argusCameraDriverParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
201 }
202 }
203
204 if (m_parser_is_strict && extra_params_found)
205 {
206 return false;
207 }
208 }
209 */
210 return true;
211}
212
213
215{
216 std::string doc;
217 doc = doc + std::string("\n=============================================\n");
218 doc = doc + std::string("This is the help for device: argusCameraDriver\n");
219 doc = doc + std::string("\n");
220 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
221 doc = doc + std::string("'d': Enumeration of the camera device\n");
222 doc = doc + std::string("'period': Refresh period of acquistion of the camera in s\n");
223 doc = doc + std::string("'rotation': Rotation applied from the center of the image\n");
224 doc = doc + std::string("'width': Width of the images requested to the camera\n");
225 doc = doc + std::string("'height': Height of the images requested to the camera\n");
226 doc = doc + std::string("'rotation_with_crop': The rotation, if the param is true, is obtained swapping x with y\n");
227 doc = doc + std::string("\n");
228 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
229 doc = doc + " yarpdev --device argusCamera --d 0 --period 0.033 --rotation 0.0 --width 640 --height 480 --rotation_with_crop false\n";
230 doc = doc + std::string("Using only mandatory params:\n");
231 doc = doc + " yarpdev --device argusCamera\n";
232 doc = doc + std::string("=============================================\n\n"); return doc;
233}
#define yError(...)
Definition Log.h:361
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::vector< std::string > getListOfParams() const override
Return a list of all params used by the device.
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 YARP_LOG_COMPONENT(name,...)