YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Localization2D_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: Fri Aug 2 15:24:54 2024
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(Localization2D_nws_ros2ParamsCOMPONENT, "yarp.device.Localization2D_nws_ros2")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("period");
32 params.push_back("node_name");
33 params.push_back("ROS::parent_frame_id");
34 params.push_back("ROS::child_frame_id");
35 return params;
36}
37
38
40{
41 //Check for --help option
42 if (config.check("help"))
43 {
44 yCInfo(Localization2D_nws_ros2ParamsCOMPONENT) << getDocumentationOfDeviceParams();
45 }
46
47 std::string config_string = config.toString();
48 yarp::os::Property prop_check(config_string.c_str());
49 //Parser of parameter period
50 {
51 if (config.check("period"))
52 {
53 m_period = config.find("period").asFloat64();
54 yCInfo(Localization2D_nws_ros2ParamsCOMPONENT) << "Parameter 'period' using value:" << m_period;
55 }
56 else
57 {
58 yCInfo(Localization2D_nws_ros2ParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period;
59 }
60 prop_check.unput("period");
61 }
62
63 //Parser of parameter node_name
64 {
65 if (config.check("node_name"))
66 {
67 m_node_name = config.find("node_name").asString();
68 yCInfo(Localization2D_nws_ros2ParamsCOMPONENT) << "Parameter 'node_name' using value:" << m_node_name;
69 }
70 else
71 {
72 yCError(Localization2D_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'node_name' not found!";
73 yCError(Localization2D_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The name of the ROS2 node";
74 return false;
75 }
76 prop_check.unput("node_name");
77 }
78
79 //Parser of parameter ROS::parent_frame_id
80 {
81 yarp::os::Bottle sectionp;
82 sectionp = config.findGroup("ROS");
83 if (sectionp.check("parent_frame_id"))
84 {
85 m_ROS_parent_frame_id = sectionp.find("parent_frame_id").asString();
86 yCInfo(Localization2D_nws_ros2ParamsCOMPONENT) << "Parameter 'ROS::parent_frame_id' using value:" << m_ROS_parent_frame_id;
87 }
88 else
89 {
90 yCError(Localization2D_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'ROS::parent_frame_id' not found!";
91 yCError(Localization2D_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The name of the odom data parent frame";
92 return false;
93 }
94 prop_check.unput("ROS::parent_frame_id");
95 }
96
97 //Parser of parameter ROS::child_frame_id
98 {
99 yarp::os::Bottle sectionp;
100 sectionp = config.findGroup("ROS");
101 if (sectionp.check("child_frame_id"))
102 {
103 m_ROS_child_frame_id = sectionp.find("child_frame_id").asString();
104 yCInfo(Localization2D_nws_ros2ParamsCOMPONENT) << "Parameter 'ROS::child_frame_id' using value:" << m_ROS_child_frame_id;
105 }
106 else
107 {
108 yCError(Localization2D_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'ROS::child_frame_id' not found!";
109 yCError(Localization2D_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The name of the odom data child frame";
110 return false;
111 }
112 prop_check.unput("ROS::child_frame_id");
113 }
114
115 /*
116 //This code check if the user set some parameter which are not check by the parser
117 //If the parser is set in strict mode, this will generate an error
118 if (prop_check.size() > 0)
119 {
120 bool extra_params_found = false;
121 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
122 {
123 if (m_parser_is_strict)
124 {
125 yCError(Localization2D_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
126 extra_params_found = true;
127 }
128 else
129 {
130 yCWarning(Localization2D_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
131 }
132 }
133
134 if (m_parser_is_strict && extra_params_found)
135 {
136 return false;
137 }
138 }
139 */
140 return true;
141}
142
143
145{
146 std::string doc;
147 doc = doc + std::string("\n=============================================\n");
148 doc = doc + std::string("This is the help for device: Localization2D_nws_ros2\n");
149 doc = doc + std::string("\n");
150 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
151 doc = doc + std::string("'period': The PeriodicThread period in seconds\n");
152 doc = doc + std::string("'node_name': The name of the ROS2 node\n");
153 doc = doc + std::string("'ROS::parent_frame_id': The name of the odom data parent frame\n");
154 doc = doc + std::string("'ROS::child_frame_id': The name of the odom data child frame\n");
155 doc = doc + std::string("\n");
156 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
157 doc = doc + " yarpdev --device localization2D_nws_ros2 --period 0.01 --node_name <mandatory_value> --ROS::parent_frame_id <mandatory_value> --ROS::child_frame_id <mandatory_value>\n";
158 doc = doc + std::string("Using only mandatory params:\n");
159 doc = doc + " yarpdev --device localization2D_nws_ros2 --node_name <mandatory_value> --ROS::parent_frame_id <mandatory_value> --ROS::child_frame_id <mandatory_value>\n";
160 doc = doc + std::string("=============================================\n\n"); return doc;
161}
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 parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
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 Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)