iCub-main
Loading...
Searching...
No Matches
RawValuesPublisherRemapper_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: Mon Sep 15 14:23:48 2025
12
13
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Value.h>
17
18namespace {
19 YARP_LOG_COMPONENT(RawValuesPublisherRemapperParamsCOMPONENT, "yarp.device.RawValuesPublisherRemapper")
20}
21
22
26
27
29{
30 std::vector<std::string> params;
31 params.push_back("axesNames");
32 params.push_back("joints");
33 return params;
34}
35
36
37bool RawValuesPublisherRemapper_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const
38{
39 if (paramName =="axesNames")
40 {
41 return false;
42 }
43 if (paramName =="joints")
44 {
45 paramValue = std::to_string(m_joints);
46 return true;
47 }
48
49 yError() <<"parameter '" << paramName << "' was not found";
50 return false;
51
52}
53
54
56{
57 //This is a sub-optimal solution.
58 //Ideally getConfiguration() should return all parameters but it is currently
59 //returning only user provided parameters (excluding default values)
60 //This behaviour will be fixed in the near future.
61 std::string s_cfg = m_provided_configuration;
62 return s_cfg;
63}
64
65bool RawValuesPublisherRemapper_ParamsParser::parseParams(const yarp::os::Searchable & config)
66{
67 //Check for --help option
68 if (config.check("help"))
69 {
70 yCInfo(RawValuesPublisherRemapperParamsCOMPONENT) << getDocumentationOfDeviceParams();
71 }
72
73 m_provided_configuration = config.toString();
74 yarp::os::Property prop_check(m_provided_configuration.c_str());
75 //Parser of parameter axesNames
76 {
77 if (config.check("axesNames"))
78 {
79 {
80 m_axesNames.clear();
81 yarp::os::Bottle* tempBot = config.find("axesNames").asList();
82 if (tempBot)
83 {
84 std::string tempBots = tempBot->toString();
85 for (size_t i=0; i<tempBot->size(); i++)
86 {
87 m_axesNames.push_back(tempBot->get(i).asString());
88 }
89 }
90 else
91 {
92 yCError(RawValuesPublisherRemapperParamsCOMPONENT) <<"parameter 'axesNames' is not a properly formatted bottle";
93 }
94 }
95 yCInfo(RawValuesPublisherRemapperParamsCOMPONENT) << "Parameter 'axesNames' using value:" << m_axesNames;
96 }
97 else
98 {
99 yCError(RawValuesPublisherRemapperParamsCOMPONENT) << "Mandatory parameter 'axesNames' not found!";
100 yCError(RawValuesPublisherRemapperParamsCOMPONENT) << "Description of the parameter: List of axes names";
101 return false;
102 }
103 prop_check.unput("axesNames");
104 }
105
106 //Parser of parameter joints
107 {
108 if (config.check("joints"))
109 {
110 m_joints = config.find("joints").asInt64();
111 yCInfo(RawValuesPublisherRemapperParamsCOMPONENT) << "Parameter 'joints' using value:" << m_joints;
112 }
113 else
114 {
115 yCInfo(RawValuesPublisherRemapperParamsCOMPONENT) << "Parameter 'joints' using DEFAULT value:" << m_joints;
116 }
117 prop_check.unput("joints");
118 }
119
120 /*
121 //This code check if the user set some parameter which are not check by the parser
122 //If the parser is set in strict mode, this will generate an error
123 if (prop_check.size() > 0)
124 {
125 bool extra_params_found = false;
126 for (auto it=prop_check.begin(); it!=prop_check.end(); it++)
127 {
128 if (m_parser_is_strict)
129 {
130 yCError(RawValuesPublisherRemapperParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!";
131 extra_params_found = true;
132 }
133 else
134 {
135 yCWarning(RawValuesPublisherRemapperParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!";
136 }
137 }
138
139 if (m_parser_is_strict && extra_params_found)
140 {
141 return false;
142 }
143 }
144 */
145 return true;
146}
147
148
150{
151 std::string doc;
152 doc = doc + std::string("\n=============================================\n");
153 doc = doc + std::string("This is the help for device: RawValuesPublisherRemapper\n");
154 doc = doc + std::string("\n");
155 doc = doc + std::string("This is the list of the parameters accepted by the device:\n");
156 doc = doc + std::string("'axesNames': List of axes names\n");
157 doc = doc + std::string("'joints': Number of control boards to be remapped\n");
158 doc = doc + std::string("\n");
159 doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n");
160 doc = doc + " yarpdev --device rawvaluespublisherremapper --axesNames <mandatory_value> --joints 1\n";
161 doc = doc + std::string("Using only mandatory params:\n");
162 doc = doc + " yarpdev --device rawvaluespublisherremapper --axesNames <mandatory_value>\n";
163 doc = doc + std::string("=============================================\n\n"); return doc;
164}
bool parseParams(const yarp::os::Searchable &config) override
bool getParamValue(const std::string &paramName, std::string &paramValue) const override
std::vector< std::string > getListOfParams() const override