forked from robotology/yarp-devices-ros2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ParamsParser to Map2D_nws_ros2
Signed-off-by: Ettore Landini <[email protected]>
- Loading branch information
1 parent
d258a0f
commit 584bc88
Showing
6 changed files
with
293 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
183 changes: 183 additions & 0 deletions
183
src/devices/map2D_nws_ros2/Map2D_nws_ros2_ParamsParser.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) | ||
* SPDX-License-Identifier: LGPL-2.1-or-later | ||
*/ | ||
|
||
|
||
// Generated by yarpDeviceParamParserGenerator (1.0) | ||
// This is an automatically generated file. Please do not edit it. | ||
// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON. | ||
|
||
// Generated on: Mon Aug 26 14:52:35 2024 | ||
|
||
|
||
#include "Map2D_nws_ros2_ParamsParser.h" | ||
#include <yarp/os/LogStream.h> | ||
#include <yarp/os/Value.h> | ||
|
||
namespace { | ||
YARP_LOG_COMPONENT(Map2D_nws_ros2ParamsCOMPONENT, "yarp.device.Map2D_nws_ros2") | ||
} | ||
|
||
|
||
Map2D_nws_ros2_ParamsParser::Map2D_nws_ros2_ParamsParser() | ||
{ | ||
} | ||
|
||
|
||
std::vector<std::string> Map2D_nws_ros2_ParamsParser::getListOfParams() const | ||
{ | ||
std::vector<std::string> params; | ||
params.push_back("name"); | ||
params.push_back("getmap"); | ||
params.push_back("getmapbyname"); | ||
params.push_back("roscmdparser"); | ||
params.push_back("markers_pub"); | ||
params.push_back("node_name"); | ||
return params; | ||
} | ||
|
||
|
||
bool Map2D_nws_ros2_ParamsParser::parseParams(const yarp::os::Searchable & config) | ||
{ | ||
//Check for --help option | ||
if (config.check("help")) | ||
{ | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << getDocumentationOfDeviceParams(); | ||
} | ||
|
||
std::string config_string = config.toString(); | ||
yarp::os::Property prop_check(config_string.c_str()); | ||
//Parser of parameter name | ||
{ | ||
if (config.check("name")) | ||
{ | ||
m_name = config.find("name").asString(); | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'name' using value:" << m_name; | ||
} | ||
else | ||
{ | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'name' using DEFAULT value:" << m_name; | ||
} | ||
prop_check.unput("name"); | ||
} | ||
|
||
//Parser of parameter getmap | ||
{ | ||
if (config.check("getmap")) | ||
{ | ||
m_getmap = config.find("getmap").asString(); | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'getmap' using value:" << m_getmap; | ||
} | ||
else | ||
{ | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'getmap' using DEFAULT value:" << m_getmap; | ||
} | ||
prop_check.unput("getmap"); | ||
} | ||
|
||
//Parser of parameter getmapbyname | ||
{ | ||
if (config.check("getmapbyname")) | ||
{ | ||
m_getmapbyname = config.find("getmapbyname").asString(); | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'getmapbyname' using value:" << m_getmapbyname; | ||
} | ||
else | ||
{ | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'getmapbyname' using DEFAULT value:" << m_getmapbyname; | ||
} | ||
prop_check.unput("getmapbyname"); | ||
} | ||
|
||
//Parser of parameter roscmdparser | ||
{ | ||
if (config.check("roscmdparser")) | ||
{ | ||
m_roscmdparser = config.find("roscmdparser").asString(); | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'roscmdparser' using value:" << m_roscmdparser; | ||
} | ||
else | ||
{ | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'roscmdparser' using DEFAULT value:" << m_roscmdparser; | ||
} | ||
prop_check.unput("roscmdparser"); | ||
} | ||
|
||
//Parser of parameter markers_pub | ||
{ | ||
if (config.check("markers_pub")) | ||
{ | ||
m_markers_pub = config.find("markers_pub").asString(); | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'markers_pub' using value:" << m_markers_pub; | ||
} | ||
else | ||
{ | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'markers_pub' using DEFAULT value:" << m_markers_pub; | ||
} | ||
prop_check.unput("markers_pub"); | ||
} | ||
|
||
//Parser of parameter node_name | ||
{ | ||
if (config.check("node_name")) | ||
{ | ||
m_node_name = config.find("node_name").asString(); | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'node_name' using value:" << m_node_name; | ||
} | ||
else | ||
{ | ||
yCInfo(Map2D_nws_ros2ParamsCOMPONENT) << "Parameter 'node_name' using DEFAULT value:" << m_node_name; | ||
} | ||
prop_check.unput("node_name"); | ||
} | ||
|
||
/* | ||
//This code check if the user set some parameter which are not check by the parser | ||
//If the parser is set in strict mode, this will generate an error | ||
if (prop_check.size() > 0) | ||
{ | ||
bool extra_params_found = false; | ||
for (auto it=prop_check.begin(); it!=prop_check.end(); it++) | ||
{ | ||
if (m_parser_is_strict) | ||
{ | ||
yCError(Map2D_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!"; | ||
extra_params_found = true; | ||
} | ||
else | ||
{ | ||
yCWarning(Map2D_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!"; | ||
} | ||
} | ||
if (m_parser_is_strict && extra_params_found) | ||
{ | ||
return false; | ||
} | ||
} | ||
*/ | ||
return true; | ||
} | ||
|
||
|
||
std::string Map2D_nws_ros2_ParamsParser::getDocumentationOfDeviceParams() const | ||
{ | ||
std::string doc; | ||
doc = doc + std::string("\n=============================================\n"); | ||
doc = doc + std::string("This is the help for device: Map2D_nws_ros2\n"); | ||
doc = doc + std::string("\n"); | ||
doc = doc + std::string("This is the list of the parameters accepted by the device:\n"); | ||
doc = doc + std::string("'name': Device name prefix\n"); | ||
doc = doc + std::string("'getmap': The \"GetMap\" ROS service name\n"); | ||
doc = doc + std::string("'getmapbyname': The \"GetMapByName\" ROS2 custom service name\n"); | ||
doc = doc + std::string("'roscmdparser': The \"BasicTypes\" ROS service name\n"); | ||
doc = doc + std::string("'markers_pub': The visual markers array publisher name\n"); | ||
doc = doc + std::string("'node_name': The ROS2 node name. If absent, the device name will be used\n"); | ||
doc = doc + std::string("\n"); | ||
doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n"); | ||
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"; | ||
doc = doc + std::string("Using only mandatory params:\n"); | ||
doc = doc + " yarpdev --device map2D_nws_ros2\n"; | ||
doc = doc + std::string("=============================================\n\n"); return doc; | ||
} |
Oops, something went wrong.