YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Rangefinder2D_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:41 2025
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(Rangefinder2D_nws_yarpParamsCOMPONENT, "yarp.device.Rangefinder2D_nws_yarp")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("period");
32 params.push_back("name");
33 params.push_back("frame_id");
34 return params;
35}
36
37
38bool Rangefinder2D_nws_yarp_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
39{
40 if (paramName =="period")
41 {
42 paramValue = std::to_string(m_period);
43 return true;
44 }
45 if (paramName =="name")
46 {
47 paramValue = m_name;
48 return true;
49 }
50 if (paramName =="frame_id")
51 {
52 paramValue = m_frame_id;
53 return true;
54 }
55
56 yError() <<"parameter '" << paramName << "' was not found";
57 return false;
58
59}
60
61
63{
64 //This is a sub-optimal solution.
65 //Ideally getConfiguration() should return all parameters but it is currently
66 //returning only user provided parameters (excluding default values)
67 //This behaviour will be fixed in the near future.
68 std::string s_cfg = m_provided_configuration;
69 return s_cfg;
70}
71
73{
74 //Check for --help option
75 if (config.check("help"))
76 {
77 yCInfo(Rangefinder2D_nws_yarpParamsCOMPONENT) << getDocumentationOfDeviceParams();
78 }
79
82 //Parser of parameter period
83 {
84 if (config.check("period"))
85 {
86 m_period = config.find("period").asFloat64();
87 yCInfo(Rangefinder2D_nws_yarpParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
88 }
89 else
90 {
91 yCInfo(Rangefinder2D_nws_yarpParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
92 }
93 prop_check.unput("period");
94 }
95
96 //Parser of parameter name
97 {
98 if (config.check("name"))
99 {
100 m_name = config.find("name").asString();
101 yCInfo(Rangefinder2D_nws_yarpParamsCOMPONENT) << "Parameter 'name' using value:" << m_name;
102 }
103 else
104 {
105 yCError(Rangefinder2D_nws_yarpParamsCOMPONENT) << "Mandatory parameter 'name' not found!";
106 yCError(Rangefinder2D_nws_yarpParamsCOMPONENT) << "Description of the parameter: Prefix name of the ports opened by the wrapper, e.g. /robotName/Rangefinder2DSensor";
107 return false;
108 }
109 prop_check.unput("name");
110 }
111
112 //Parser of parameter frame_id
113 {
114 if (config.check("frame_id"))
115 {
116 m_frame_id = config.find("frame_id").asString();
117 yCInfo(Rangefinder2D_nws_yarpParamsCOMPONENT) << "Parameter 'frame_id' using value:" << m_frame_id;
118 }
119 else
120 {
121 yCInfo(Rangefinder2D_nws_yarpParamsCOMPONENT) << "Parameter 'frame_id' using DEFAULT value:" << m_frame_id;
122 }
123 prop_check.unput("frame_id");
124 }
125
126 /*
127 //This code check if the user set some parameter which are not check by the parser
128 //If the parser is set in strict mode, this will generate an error
129 if (prop_check.size() > 0)
130 {
131 bool extra_params_found = false;
132 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
133 {
134 if (m_parser_is_strict)
135 {
136 yCError(Rangefinder2D_nws_yarpParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
137 extra_params_found = true;
138 }
139 else
140 {
141 yCWarning(Rangefinder2D_nws_yarpParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
142 }
143 }
144
145 if (m_parser_is_strict && extra_params_found)
146 {
147 return false;
148 }
149 }
150 */
151 return true;
152}
153
154
156{
157 std::string doc;
158 doc = doc + std::string("\n=============================================\n");
159 doc = doc + std::string("This is the help for device: Rangefinder2D_nws_yarp\n");
160 doc = doc + std::string("\n");
161 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
162 doc = doc + std::string("'period': refresh period of the broadcasted values in s\n");
163 doc = doc + std::string("'name': Prefix name of the ports opened by the wrapper, e.g. /robotName/Rangefinder2DSensor\n");
164 doc = doc + std::string("'frame_id': name of the attached frame\n");
165 doc = doc + std::string("\n");
166 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
167 doc = doc + " yarpdev --device rangefinder2D_nws_yarp --period 0.02 --name <mandatory_value> --frame_id <optional_value>\n";
168 doc = doc + std::string("Using only mandatory params:\n");
169 doc = doc + " yarpdev --device rangefinder2D_nws_yarp --name <mandatory_value>\n";
170 doc = doc + std::string("=============================================\n\n"); return doc;
171}
#define yError(...)
Definition Log.h:361
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.
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 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,...)