YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Localization2D_nws_yarp_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:42 2025
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(Localization2D_nws_yarpParamsCOMPONENT, "yarp.device.Localization2D_nws_yarp")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("GENERAL::period");
32 params.push_back("GENERAL::retrieve_position_periodically");
33 params.push_back("GENERAL::name");
34 params.push_back("GENERAL::publish_odometry");
35 params.push_back("GENERAL::publish_location");
36 return params;
37}
38
39
40bool Localization2D_nws_yarp_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
41{
42 if (paramName =="GENERAL::period")
43 {
44 paramValue = std::to_string(m_GENERAL_period);
45 return true;
46 }
47 if (paramName =="GENERAL::retrieve_position_periodically")
48 {
49 if (m_GENERAL_retrieve_position_periodically==true) paramValue = "true";
50 else paramValue = "false";
51 return true;
52 }
53 if (paramName =="GENERAL::name")
54 {
55 paramValue = m_GENERAL_name;
56 return true;
57 }
58 if (paramName =="GENERAL::publish_odometry")
59 {
60 if (m_GENERAL_publish_odometry==true) paramValue = "true";
61 else paramValue = "false";
62 return true;
63 }
64 if (paramName =="GENERAL::publish_location")
65 {
66 if (m_GENERAL_publish_location==true) paramValue = "true";
67 else paramValue = "false";
68 return true;
69 }
70
71 yError() <<"parameter '" << paramName << "' was not found";
72 return false;
73
74}
75
76
78{
79 //This is a sub-optimal solution.
80 //Ideally getConfiguration() should return all parameters but it is currently
81 //returning only user provided parameters (excluding default values)
82 //This behaviour will be fixed in the near future.
83 std::string s_cfg = m_provided_configuration;
84 return s_cfg;
85}
86
88{
89 //Check for --help option
90 if (config.check("help"))
91 {
92 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << getDocumentationOfDeviceParams();
93 }
94
97 //Parser of parameter GENERAL::period
98 {
99 yarp::os::Bottle sectionp;
100 sectionp = config.findGroup("GENERAL");
101 if (sectionp.check("period"))
102 {
103 m_GENERAL_period = sectionp.find("period").asFloat64();
104 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::period' using value:" << m_GENERAL_period;
105 }
106 else
107 {
108 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::period' using DEFAULT value:" << m_GENERAL_period;
109 }
110 prop_check.unput("GENERAL::period");
111 }
112
113 //Parser of parameter GENERAL::retrieve_position_periodically
114 {
115 yarp::os::Bottle sectionp;
116 sectionp = config.findGroup("GENERAL");
117 if (sectionp.check("retrieve_position_periodically"))
118 {
119 m_GENERAL_retrieve_position_periodically = sectionp.find("retrieve_position_periodically").asBool();
120 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::retrieve_position_periodically' using value:" << m_GENERAL_retrieve_position_periodically;
121 }
122 else
123 {
124 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::retrieve_position_periodically' using DEFAULT value:" << m_GENERAL_retrieve_position_periodically;
125 }
126 prop_check.unput("GENERAL::retrieve_position_periodically");
127 }
128
129 //Parser of parameter GENERAL::name
130 {
131 yarp::os::Bottle sectionp;
132 sectionp = config.findGroup("GENERAL");
133 if (sectionp.check("name"))
134 {
135 m_GENERAL_name = sectionp.find("name").asString();
136 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::name' using value:" << m_GENERAL_name;
137 }
138 else
139 {
140 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::name' using DEFAULT value:" << m_GENERAL_name;
141 }
142 prop_check.unput("GENERAL::name");
143 }
144
145 //Parser of parameter GENERAL::publish_odometry
146 {
147 yarp::os::Bottle sectionp;
148 sectionp = config.findGroup("GENERAL");
149 if (sectionp.check("publish_odometry"))
150 {
151 m_GENERAL_publish_odometry = sectionp.find("publish_odometry").asBool();
152 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::publish_odometry' using value:" << m_GENERAL_publish_odometry;
153 }
154 else
155 {
156 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::publish_odometry' using DEFAULT value:" << m_GENERAL_publish_odometry;
157 }
158 prop_check.unput("GENERAL::publish_odometry");
159 }
160
161 //Parser of parameter GENERAL::publish_location
162 {
163 yarp::os::Bottle sectionp;
164 sectionp = config.findGroup("GENERAL");
165 if (sectionp.check("publish_location"))
166 {
167 m_GENERAL_publish_location = sectionp.find("publish_location").asBool();
168 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::publish_location' using value:" << m_GENERAL_publish_location;
169 }
170 else
171 {
172 yCInfo(Localization2D_nws_yarpParamsCOMPONENT) << "Parameter 'GENERAL::publish_location' using DEFAULT value:" << m_GENERAL_publish_location;
173 }
174 prop_check.unput("GENERAL::publish_location");
175 }
176
177 /*
178 //This code check if the user set some parameter which are not check by the parser
179 //If the parser is set in strict mode, this will generate an error
180 if (prop_check.size() > 0)
181 {
182 bool extra_params_found = false;
183 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
184 {
185 if (m_parser_is_strict)
186 {
187 yCError(Localization2D_nws_yarpParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
188 extra_params_found = true;
189 }
190 else
191 {
192 yCWarning(Localization2D_nws_yarpParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
193 }
194 }
195
196 if (m_parser_is_strict && extra_params_found)
197 {
198 return false;
199 }
200 }
201 */
202 return true;
203}
204
205
207{
208 std::string doc;
209 doc = doc + std::string("\n=============================================\n");
210 doc = doc + std::string("This is the help for device: Localization2D_nws_yarp\n");
211 doc = doc + std::string("\n");
212 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
213 doc = doc + std::string("'GENERAL::period': The period of the working thread\n");
214 doc = doc + std::string("'GENERAL::retrieve_position_periodically': If true, the subdevice is asked periodically to retrieve the current location. Otherwise the current location is obtained asynchronously when a getCurrentPosition() command is issued.\n");
215 doc = doc + std::string("'GENERAL::name': The name of the server, used as a prefix for the opened ports\n");
216 doc = doc + std::string("'GENERAL::publish_odometry': Periodically publish odometry data over the network\n");
217 doc = doc + std::string("'GENERAL::publish_location': PEriodically publish location data over the network\n");
218 doc = doc + std::string("\n");
219 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
220 doc = doc + " yarpdev --device localization2D_nws_yarp --GENERAL::period 0.01 --GENERAL::retrieve_position_periodically true --GENERAL::name /localization2D_nws_yarp --GENERAL::publish_odometry true --GENERAL::publish_location true\n";
221 doc = doc + std::string("Using only mandatory params:\n");
222 doc = doc + " yarpdev --device localization2D_nws_yarp\n";
223 doc = doc + std::string("=============================================\n\n"); return doc;
224}
#define yError(...)
Definition Log.h:361
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.
std::string getDocumentationOfDeviceParams() const override
Get the documentation of the DeviceDriver's parameters.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
Return the value (represented as a string) of the requested parameter.
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 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 bool asBool() const
Get boolean value.
Definition Value.cpp:186
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
#define yCInfo(component,...)
#define YARP_LOG_COMPONENT(name,...)