YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Map2D_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 (1.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 Aug 26 14:52:35 2024
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(Map2D_nws_ros2ParamsCOMPONENT, "yarp.device.Map2D_nws_ros2")
20}
21
22
26
27
28std::vector<std::string> Map2D_nws_ros2_ParamsParser::getListOfParams() const
29{
30 std::vector<std::string> params;
31 params.push_back("name");
32 params.push_back("getmap");
33 params.push_back("getmapbyname");
34 params.push_back("roscmdparser");
35 params.push_back("markers_pub");
36 params.push_back("node_name");
37 return params;
38}
39
40
42{
43 //Check for --help option
44 if (config.check("help"))
45 {
46 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << getDocumentationOfDeviceParams();
47 }
48
49 std::string config_string = config.toString();
50 yarp::os::Property prop_check(config_string.c_str());
51 //Parser of parameter name
52 {
53 if (config.check("name"))
54 {
55 m_name = config.find("name").asString();
56 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'name' using value:" << m_name;
57 }
58 else
59 {
60 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'name' using DEFAULT value:" << m_name;
61 }
62 prop_check.unput("name");
63 }
64
65 //Parser of parameter getmap
66 {
67 if (config.check("getmap"))
68 {
69 m_getmap = config.find("getmap").asString();
70 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'getmap' using value:" << m_getmap;
71 }
72 else
73 {
74 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'getmap' using DEFAULT value:" << m_getmap;
75 }
76 prop_check.unput("getmap");
77 }
78
79 //Parser of parameter getmapbyname
80 {
81 if (config.check("getmapbyname"))
82 {
83 m_getmapbyname = config.find("getmapbyname").asString();
84 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'getmapbyname' using value:" << m_getmapbyname;
85 }
86 else
87 {
88 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'getmapbyname' using DEFAULT value:" << m_getmapbyname;
89 }
90 prop_check.unput("getmapbyname");
91 }
92
93 //Parser of parameter roscmdparser
94 {
95 if (config.check("roscmdparser"))
96 {
97 m_roscmdparser = config.find("roscmdparser").asString();
98 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'roscmdparser' using value:" << m_roscmdparser;
99 }
100 else
101 {
102 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'roscmdparser' using DEFAULT value:" << m_roscmdparser;
103 }
104 prop_check.unput("roscmdparser");
105 }
106
107 //Parser of parameter markers_pub
108 {
109 if (config.check("markers_pub"))
110 {
111 m_markers_pub = config.find("markers_pub").asString();
112 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'markers_pub' using value:" << m_markers_pub;
113 }
114 else
115 {
116 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'markers_pub' using DEFAULT value:" << m_markers_pub;
117 }
118 prop_check.unput("markers_pub");
119 }
120
121 //Parser of parameter node_name
122 {
123 if (config.check("node_name"))
124 {
125 m_node_name = config.find("node_name").asString();
126 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'node_name' using value:" << m_node_name;
127 }
128 else
129 {
130 yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'node_name' using DEFAULT value:" << m_node_name;
131 }
132 prop_check.unput("node_name");
133 }
134
135 /*
136 //This code check if the user set some parameter which are not check by the parser
137 //If the parser is set in strict mode, this will generate an error
138 if (prop_check.size() > 0)
139 {
140 bool extra_params_found = false;
141 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
142 {
143 if (m_parser_is_strict)
144 {
145 yCError(Map2D_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
146 extra_params_found = true;
147 }
148 else
149 {
150 yCWarning(Map2D_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
151 }
152 }
153
154 if (m_parser_is_strict && extra_params_found)
155 {
156 return false;
157 }
158 }
159 */
160 return true;
161}
162
163
165{
166 std::string doc;
167 doc = doc + std::string("\n=============================================\n");
168 doc = doc + std::string("This is the help for device: Map2D_nws_ros2\n");
169 doc = doc + std::string("\n");
170 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
171 doc = doc + std::string("'name': Device name prefix\n");
172 doc = doc + std::string("'getmap': The \"GetMap\" ROS service name\n");
173 doc = doc + std::string("'getmapbyname': The \"GetMapByName\" ROS2 custom service name\n");
174 doc = doc + std::string("'roscmdparser': The \"BasicTypes\" ROS service name\n");
175 doc = doc + std::string("'markers_pub': The visual markers array publisher name\n");
176 doc = doc + std::string("'node_name': The ROS2 node name. If absent, the device name will be used\n");
177 doc = doc + std::string("\n");
178 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
179 doc = doc + " yarpdev --device map2D_nws_ros2 --name map2D_nws_ros2 --getmap getMap --getmapbyname getMapByName --roscmdparser rosCmdParser --markers_pub locationServerMarkers --node_name map2D_nws_ros2\n";
180 doc = doc + std::string("Using only mandatory params:\n");
181 doc = doc + " yarpdev --device map2D_nws_ros2\n";
182 doc = doc + std::string("=============================================\n\n"); return doc;
183}
std::vector< std::string > getListOfParams() const override
Return a list of all params used by 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.
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,...)