From c3b0ee69c773eb56712aa69735e29607992b9135 Mon Sep 17 00:00:00 2001 From: Marco Randazzo Date: Tue, 27 May 2025 11:21:02 +0200 Subject: [PATCH] added ParamParser to devices: FrameTransformGet_nws_yarp added ParamParser to devices: FrameTransformGet_nwc_yarp added ParamParser to devices: FrameTransformSet_nws_yarp added ParamParser to devices: FrameTransformSet_nwc_yarp --- .../frameTransformGet_nwc_yarp/CMakeLists.txt | 3 + .../FrameTransformGet_nwc_yarp.cpp | 16 +- .../FrameTransformGet_nwc_yarp.h | 19 +- ...rameTransformGet_nwc_yarp_ParamsParser.cpp | 256 ++++++++++++++++++ .../FrameTransformGet_nwc_yarp_ParamsParser.h | 91 +++++++ .../FrameTransformGet_nwc_yarp_params.md | 7 + .../frameTransformGet_nws_yarp/CMakeLists.txt | 3 + .../FrameTransformGet_nws_yarp.cpp | 6 +- .../FrameTransformGet_nws_yarp.h | 15 +- ...rameTransformGet_nws_yarp_ParamsParser.cpp | 213 +++++++++++++++ .../FrameTransformGet_nws_yarp_ParamsParser.h | 85 ++++++ .../FrameTransformGet_nws_yarp_params.md | 5 + .../frameTransformSet_nwc_yarp/CMakeLists.txt | 3 + .../FrameTransformSet_nwc_yarp.cpp | 5 +- .../FrameTransformSet_nwc_yarp.h | 13 +- ...rameTransformSet_nwc_yarp_ParamsParser.cpp | 192 +++++++++++++ .../FrameTransformSet_nwc_yarp_ParamsParser.h | 82 ++++++ .../FrameTransformSet_nwc_yarp_params.md | 4 + .../frameTransformSet_nws_yarp/CMakeLists.txt | 3 + .../FrameTransformSet_nws_yarp.cpp | 5 +- .../FrameTransformSet_nws_yarp.h | 11 +- ...rameTransformSet_nws_yarp_ParamsParser.cpp | 149 ++++++++++ .../FrameTransformSet_nws_yarp_ParamsParser.h | 76 ++++++ .../FrameTransformSet_nws_yarp_params.md | 2 + 24 files changed, 1203 insertions(+), 61 deletions(-) create mode 100644 src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_ParamsParser.cpp create mode 100644 src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_ParamsParser.h create mode 100644 src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_params.md create mode 100644 src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_ParamsParser.cpp create mode 100644 src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_ParamsParser.h create mode 100644 src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_params.md create mode 100644 src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_ParamsParser.cpp create mode 100644 src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_ParamsParser.h create mode 100644 src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_params.md create mode 100644 src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_ParamsParser.cpp create mode 100644 src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_ParamsParser.h create mode 100644 src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_params.md diff --git a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/CMakeLists.txt b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/CMakeLists.txt index 8bd5f3e91d9..3aa6e7620fd 100644 --- a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/CMakeLists.txt +++ b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/CMakeLists.txt @@ -10,6 +10,7 @@ yarp_prepare_plugin(frameTransformGet_nwc_yarp EXTRA_CONFIG WRAPPER=frameTransformGet_nws_yarp DEFAULT ON + GENERATE_PARSER ) if(NOT SKIP_frameTransformGet_nwc_yarp) @@ -19,6 +20,8 @@ if(NOT SKIP_frameTransformGet_nwc_yarp) PRIVATE FrameTransformGet_nwc_yarp.cpp FrameTransformGet_nwc_yarp.h + FrameTransformGet_nwc_yarp_ParamsParser.cpp + FrameTransformGet_nwc_yarp_ParamsParser.h ) target_sources(yarp_frameTransformGet_nwc_yarp PRIVATE $) diff --git a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp.cpp b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp.cpp index abb3fa3775c..1af24d742e0 100644 --- a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp.cpp +++ b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp.cpp @@ -15,10 +15,8 @@ YARP_LOG_COMPONENT(FRAMETRANSFORMGETNWCYARP, "yarp.devices.FrameTransformGet_nwc bool FrameTransformGet_nwc_yarp::open(yarp::os::Searchable& config) { - if (!yarp::os::NetworkBase::checkNetwork()) { - yCError(FRAMETRANSFORMGETNWCYARP,"Error! YARP Network is not initialized"); - return false; - } + if (!parseParams(config)) { return false; } + std::string prefix; //checking default config params bool default_config = true; @@ -71,11 +69,7 @@ bool FrameTransformGet_nwc_yarp::open(yarp::os::Searchable& config) } //checking streaming_enabled param - if(config.check("streaming_enabled")) { - m_streaming_port_enabled = config.find("streaming_enabled").asString() == "true"; - } - - if (m_streaming_port_enabled) + if (m_streaming_enabled) { yCInfo(FRAMETRANSFORMGETNWCYARP) << "Receiving transforms from Yarp port enabled"; if (config.check("input_streaming_port_prefix")){ @@ -128,7 +122,7 @@ bool FrameTransformGet_nwc_yarp::open(yarp::os::Searchable& config) bool FrameTransformGet_nwc_yarp::close() { - if (m_streaming_port_enabled) + if (m_streaming_enabled) { m_dataReader->close(); } @@ -145,7 +139,7 @@ bool FrameTransformGet_nwc_yarp::close() ReturnValue FrameTransformGet_nwc_yarp::getTransforms(std::vector& transforms) const { - if (!m_streaming_port_enabled) + if (!m_streaming_enabled) { return_getAllTransforms retrievedFromRPC = m_frameTransformStorageGetRPC.getTransformsRPC(); if(!retrievedFromRPC.retvalue) diff --git a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp.h b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp.h index 6d6f2b2ddab..860a0089cac 100644 --- a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp.h +++ b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp.h @@ -11,8 +11,8 @@ #include #include - #include +#include "FrameTransformGet_nwc_yarp_ParamsParser.h" /** * @ingroup dev_impl_nwc_yarp @@ -25,17 +25,8 @@ * When it a method of the interface is called, the request is forwarded on a RPC port (which uses the thrift FrameTransformStorageGetRPC interface) and it returns all the transforms received * from the port to the caller. * For further information see \subpage FrameTransform. - - * Parameters required by this device are: - * | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | - * |:----------------------------:|:-------------|:-------:|:------:|:--------------:|:------- -:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| - * | default-client | - | bool | - | true | No | tells whether or not the nwc is instantiated by the frameTransformClient device. If true, "/frameTransformClient" will appended to the port name prefix | - * | default-server | - | bool | - | true | No | tells whether or not the nws is instantiated by the frameTransformServer device. If true, "/frameTransformServer/frameTransformGet_nws_yarp" will appended to the port name prefix | - * | nwc_thrift_port_prefix | - | string | - | "" | No | a prefix for the nwc thrift rpc port name | - * | nws_thrift_port_prefix | - | string | - | "" | No | a prefix for the nws thrift rpc port name | - * | input_streaming_port_prefix | - | string | - | - | No | a prefix for the input streaming port name (if the port is enabled) | - * | output_streaming_port_prefix | - | string | - | - | No | a prefix for the output streaming port name (if the port is enabled) | - * | streaming_enabled | - | bool | - | false | No | if enabled, tfs are received from the streaming port instead of using RPCs | + * + * Parameters required by this device are shown in class: FrameTransformGet_nwc_yarpParamsParser * * \section FrameTransformGet_nwc_yarp_port_example Port names examples * Here follow some examples of port names obtained with different parameters configurations @@ -98,7 +89,8 @@ */ class FrameTransformGet_nwc_yarp: public yarp::dev::DeviceDriver, - public yarp::dev::IFrameTransformStorageGet + public yarp::dev::IFrameTransformStorageGet, + public FrameTransformGet_nwc_yarp_ParamsParser { class DataReader : public yarp::os::BufferedPort { @@ -135,7 +127,6 @@ class FrameTransformGet_nwc_yarp: std::string m_defaultServerPrefix{"/frameTransformServer/frameTransformGet_nws_yarp"}; //streaming port - bool m_streaming_port_enabled = false; std::string m_streaming_input_port_name; std::string m_streaming_output_port_name; DataReader* m_dataReader =nullptr; diff --git a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_ParamsParser.cpp b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_ParamsParser.cpp new file mode 100644 index 00000000000..b073305995b --- /dev/null +++ b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_ParamsParser.cpp @@ -0,0 +1,256 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + + +// Generated by yarpDeviceParamParserGenerator (2.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 May 26 10:28:39 2025 + + +#include "FrameTransformGet_nwc_yarp_ParamsParser.h" +#include +#include + +namespace { + YARP_LOG_COMPONENT(FrameTransformGet_nwc_yarpParamsCOMPONENT, "yarp.device.FrameTransformGet_nwc_yarp") +} + + +FrameTransformGet_nwc_yarp_ParamsParser::FrameTransformGet_nwc_yarp_ParamsParser() +{ +} + + +std::vector FrameTransformGet_nwc_yarp_ParamsParser::getListOfParams() const +{ + std::vector params; + params.push_back("streaming_enabled"); + params.push_back("output_streaming_port_prefix"); + params.push_back("input_streaming_port_prefix"); + params.push_back("nws_thrift_port_prefix"); + params.push_back("nwc_thrift_port_prefix"); + params.push_back("default_server"); + params.push_back("default_client"); + return params; +} + + +bool FrameTransformGet_nwc_yarp_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const +{ + if (paramName =="streaming_enabled") + { + if (m_streaming_enabled==true) paramValue = "true"; + else paramValue = "false"; + return true; + } + if (paramName =="output_streaming_port_prefix") + { + if (m_output_streaming_port_prefix==true) paramValue = "true"; + else paramValue = "false"; + return true; + } + if (paramName =="input_streaming_port_prefix") + { + paramValue = m_input_streaming_port_prefix; + return true; + } + if (paramName =="nws_thrift_port_prefix") + { + paramValue = m_nws_thrift_port_prefix; + return true; + } + if (paramName =="nwc_thrift_port_prefix") + { + paramValue = m_nwc_thrift_port_prefix; + return true; + } + if (paramName =="default_server") + { + paramValue = m_default_server; + return true; + } + if (paramName =="default_client") + { + if (m_default_client==true) paramValue = "true"; + else paramValue = "false"; + return true; + } + + yError() <<"parameter '" << paramName << "' was not found"; + return false; + +} + + +std::string FrameTransformGet_nwc_yarp_ParamsParser::getConfiguration() const +{ + //This is a sub-optimal solution. + //Ideally getConfiguration() should return all parameters but it is currently + //returning only user provided parameters (excluding default values) + //This behaviour will be fixed in the near future. + std::string s_cfg = m_provided_configuration; + return s_cfg; +} + +bool FrameTransformGet_nwc_yarp_ParamsParser::parseParams(const yarp::os::Searchable & config) +{ + //Check for --help option + if (config.check("help")) + { + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << getDocumentationOfDeviceParams(); + } + + m_provided_configuration = config.toString(); + yarp::os::Property prop_check(m_provided_configuration.c_str()); + //Parser of parameter streaming_enabled + { + if (config.check("streaming_enabled")) + { + m_streaming_enabled = config.find("streaming_enabled").asBool(); + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'streaming_enabled' using value:" << m_streaming_enabled; + } + else + { + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'streaming_enabled' using DEFAULT value:" << m_streaming_enabled; + } + prop_check.unput("streaming_enabled"); + } + + //Parser of parameter output_streaming_port_prefix + { + if (config.check("output_streaming_port_prefix")) + { + m_output_streaming_port_prefix = config.find("output_streaming_port_prefix").asBool(); + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'output_streaming_port_prefix' using value:" << m_output_streaming_port_prefix; + } + else + { + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'output_streaming_port_prefix' using DEFAULT value:" << m_output_streaming_port_prefix; + } + prop_check.unput("output_streaming_port_prefix"); + } + + //Parser of parameter input_streaming_port_prefix + { + if (config.check("input_streaming_port_prefix")) + { + m_input_streaming_port_prefix = config.find("input_streaming_port_prefix").asString(); + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'input_streaming_port_prefix' using value:" << m_input_streaming_port_prefix; + } + else + { + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'input_streaming_port_prefix' using DEFAULT value:" << m_input_streaming_port_prefix; + } + prop_check.unput("input_streaming_port_prefix"); + } + + //Parser of parameter nws_thrift_port_prefix + { + if (config.check("nws_thrift_port_prefix")) + { + m_nws_thrift_port_prefix = config.find("nws_thrift_port_prefix").asString(); + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using value:" << m_nws_thrift_port_prefix; + } + else + { + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using DEFAULT value:" << m_nws_thrift_port_prefix; + } + prop_check.unput("nws_thrift_port_prefix"); + } + + //Parser of parameter nwc_thrift_port_prefix + { + if (config.check("nwc_thrift_port_prefix")) + { + m_nwc_thrift_port_prefix = config.find("nwc_thrift_port_prefix").asString(); + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'nwc_thrift_port_prefix' using value:" << m_nwc_thrift_port_prefix; + } + else + { + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'nwc_thrift_port_prefix' using DEFAULT value:" << m_nwc_thrift_port_prefix; + } + prop_check.unput("nwc_thrift_port_prefix"); + } + + //Parser of parameter default_server + { + if (config.check("default_server")) + { + m_default_server = config.find("default_server").asString(); + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_server' using value:" << m_default_server; + } + else + { + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_server' using DEFAULT value:" << m_default_server; + } + prop_check.unput("default_server"); + } + + //Parser of parameter default_client + { + if (config.check("default_client")) + { + m_default_client = config.find("default_client").asBool(); + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_client' using value:" << m_default_client; + } + else + { + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_client' using DEFAULT value:" << m_default_client; + } + prop_check.unput("default_client"); + } + + /* + //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(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "User asking for parameter: "<name <<" which is unknown to this parser!"; + extra_params_found = true; + } + else + { + yCWarning(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "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 FrameTransformGet_nwc_yarp_ParamsParser::getDocumentationOfDeviceParams() const +{ + std::string doc; + doc = doc + std::string("\n=============================================\n"); + doc = doc + std::string("This is the help for device: FrameTransformGet_nwc_yarp\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("'streaming_enabled': tells whether or not the nwc is instantiated by the frameTransformClient device. If true, \"/frameTransformClient\" will appended to the port name prefix\n"); + doc = doc + std::string("'output_streaming_port_prefix': tells whether or not the nws is instantiated by the frameTransformServer device. If true, \"/frameTransformServer/frameTransformGet_nws_yarp\" will appended to the port name prefix\n"); + doc = doc + std::string("'input_streaming_port_prefix': a prefix for the nwc thrift rpc port name\n"); + doc = doc + std::string("'nws_thrift_port_prefix': a prefix for the nws thrift rpc port name\n"); + doc = doc + std::string("'nwc_thrift_port_prefix': a prefix for the input streaming port name (if the port is enabled)\n"); + doc = doc + std::string("'default_server': a prefix for the output streaming port name (if the port is enabled)\n"); + doc = doc + std::string("'default_client': if enabled, tfs are received from the streaming port instead of using RPCs\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 frameTransformGet_nwc_yarp --streaming_enabled true --output_streaming_port_prefix true --input_streaming_port_prefix --nws_thrift_port_prefix --nwc_thrift_port_prefix --default_server --default_client false\n"; + doc = doc + std::string("Using only mandatory params:\n"); + doc = doc + " yarpdev --device frameTransformGet_nwc_yarp\n"; + doc = doc + std::string("=============================================\n\n"); return doc; +} diff --git a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_ParamsParser.h b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_ParamsParser.h new file mode 100644 index 00000000000..76cf9c04e4e --- /dev/null +++ b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_ParamsParser.h @@ -0,0 +1,91 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + + +// Generated by yarpDeviceParamParserGenerator (2.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 May 26 10:28:39 2025 + + +#ifndef FRAMETRANSFORMGET_NWC_YARP_PARAMSPARSER_H +#define FRAMETRANSFORMGET_NWC_YARP_PARAMSPARSER_H + +#include +#include +#include +#include + +/** +* This class is the parameters parser for class FrameTransformGet_nwc_yarp. +* +* These are the used parameters: +* | Group name | Parameter name | Type | Units | Default Value | Required | Description | Notes | +* |:----------:|:----------------------------:|:------:|:-----:|:-------------:|:--------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----:| +* | - | streaming_enabled | bool | - | true | 0 | tells whether or not the nwc is instantiated by the frameTransformClient device. If true, \"/frameTransformClient\" will appended to the port name prefix | - | +* | - | output_streaming_port_prefix | bool | - | true | 0 | tells whether or not the nws is instantiated by the frameTransformServer device. If true, \"/frameTransformServer/frameTransformGet_nws_yarp\" will appended to the port name prefix | - | +* | - | input_streaming_port_prefix | string | - | - | 0 | a prefix for the nwc thrift rpc port name | - | +* | - | nws_thrift_port_prefix | string | - | - | 0 | a prefix for the nws thrift rpc port name | - | +* | - | nwc_thrift_port_prefix | string | - | - | 0 | a prefix for the input streaming port name (if the port is enabled) | - | +* | - | default_server | string | - | - | 0 | a prefix for the output streaming port name (if the port is enabled) | - | +* | - | default_client | bool | - | false | 0 | if enabled, tfs are received from the streaming port instead of using RPCs | - | +* +* The device can be launched by yarpdev using one of the following examples (with and without all optional parameters): +* \code{.unparsed} +* yarpdev --device frameTransformGet_nwc_yarp --streaming_enabled true --output_streaming_port_prefix true --input_streaming_port_prefix --nws_thrift_port_prefix --nwc_thrift_port_prefix --default_server --default_client false +* \endcode +* +* \code{.unparsed} +* yarpdev --device frameTransformGet_nwc_yarp +* \endcode +* +*/ + +class FrameTransformGet_nwc_yarp_ParamsParser : public yarp::dev::IDeviceDriverParams +{ +public: + FrameTransformGet_nwc_yarp_ParamsParser(); + ~FrameTransformGet_nwc_yarp_ParamsParser() override = default; + +public: + const std::string m_device_classname = {"FrameTransformGet_nwc_yarp"}; + const std::string m_device_name = {"frameTransformGet_nwc_yarp"}; + bool m_parser_is_strict = false; + struct parser_version_type + { + int major = 2; + int minor = 0; + }; + const parser_version_type m_parser_version = {}; + + std::string m_provided_configuration; + + const std::string m_streaming_enabled_defaultValue = {"true"}; + const std::string m_output_streaming_port_prefix_defaultValue = {"true"}; + const std::string m_input_streaming_port_prefix_defaultValue = {""}; + const std::string m_nws_thrift_port_prefix_defaultValue = {""}; + const std::string m_nwc_thrift_port_prefix_defaultValue = {""}; + const std::string m_default_server_defaultValue = {""}; + const std::string m_default_client_defaultValue = {"false"}; + + bool m_streaming_enabled = {true}; + bool m_output_streaming_port_prefix = {true}; + std::string m_input_streaming_port_prefix = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + std::string m_nws_thrift_port_prefix = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + std::string m_nwc_thrift_port_prefix = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + std::string m_default_server = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + bool m_default_client = {false}; + + bool parseParams(const yarp::os::Searchable & config) override; + std::string getDeviceClassName() const override { return m_device_classname; } + std::string getDeviceName() const override { return m_device_name; } + std::string getDocumentationOfDeviceParams() const override; + std::vector getListOfParams() const override; + bool getParamValue(const std::string& paramName, std::string& paramValue) const override; + std::string getConfiguration() const override; +}; + +#endif diff --git a/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_params.md b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_params.md new file mode 100644 index 00000000000..bd0e61c7af8 --- /dev/null +++ b/src/devices/networkWrappers/frameTransformGet_nwc_yarp/FrameTransformGet_nwc_yarp_params.md @@ -0,0 +1,7 @@ + * | | streaming_enabled | bool | - | true | No | tells whether or not the nwc is instantiated by the frameTransformClient device. If true, "/frameTransformClient" will appended to the port name prefix | + * | | output_streaming_port_prefix | bool | - | true | No | tells whether or not the nws is instantiated by the frameTransformServer device. If true, "/frameTransformServer/frameTransformGet_nws_yarp" will appended to the port name prefix | + * | | input_streaming_port_prefix | string | - | "" | No | a prefix for the nwc thrift rpc port name | + * | | nws_thrift_port_prefix | string | - | "" | No | a prefix for the nws thrift rpc port name | + * | | nwc_thrift_port_prefix | string | - | - | No | a prefix for the input streaming port name (if the port is enabled) | + * | | default_server | string | - | - | No | a prefix for the output streaming port name (if the port is enabled) | + * | | default_client | bool | - | false | No | if enabled, tfs are received from the streaming port instead of using RPCs | diff --git a/src/devices/networkWrappers/frameTransformGet_nws_yarp/CMakeLists.txt b/src/devices/networkWrappers/frameTransformGet_nws_yarp/CMakeLists.txt index 1e037960d81..b20704eea15 100644 --- a/src/devices/networkWrappers/frameTransformGet_nws_yarp/CMakeLists.txt +++ b/src/devices/networkWrappers/frameTransformGet_nws_yarp/CMakeLists.txt @@ -10,6 +10,7 @@ yarp_prepare_plugin(frameTransformGet_nws_yarp EXTRA_CONFIG WRAPPER=frameTransformGet_nws_yarp DEFAULT ON + GENERATE_PARSER ) if(NOT SKIP_frameTransformGet_nws_yarp) @@ -19,6 +20,8 @@ if(NOT SKIP_frameTransformGet_nws_yarp) PRIVATE FrameTransformGet_nws_yarp.cpp FrameTransformGet_nws_yarp.h + FrameTransformGet_nws_yarp_ParamsParser.cpp + FrameTransformGet_nws_yarp_ParamsParser.h ) target_sources(yarp_frameTransformGet_nws_yarp PRIVATE $) diff --git a/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp.cpp b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp.cpp index 82f9bafd391..6ecd13a3273 100644 --- a/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp.cpp +++ b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp.cpp @@ -23,10 +23,8 @@ m_thrift_rpcPort_Name("/frameTransformGet/rpc") /** Device driver interface */ bool FrameTransformGet_nws_yarp::open(yarp::os::Searchable &config) { - if (!yarp::os::NetworkBase::checkNetwork()) { - yCError(FRAMETRANSFORMGETNWSYARP,"Error! YARP Network is not initialized"); - return false; - } + if (!parseParams(config)) { return false; } + std::string prefix; //checking default config param bool default_config = true; diff --git a/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp.h b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp.h index 4b43779457d..54a3377c689 100644 --- a/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp.h +++ b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp.h @@ -13,7 +13,8 @@ #include #include -// TODO FIXME STE need to check subdevice option +#include "FrameTransformGet_nws_yarp_ParamsParser.h" + /** * @ingroup dev_impl_nws_yarp * @@ -27,14 +28,7 @@ * The attached device must implement an IFrameTransformStorageGet interface. * For further information see \subpage FrameTransform. * - * Parameters required by this device are: - * | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | - * |:----------------------------:|:-----------------------:|:-------:|:--------------:|:--------------:|:------- -:|:-------------------------------------------------------------------------------------------------------------------------------------------------------:| - * | default-config | - | bool | - | true | No | tells whether or not the nws is instanciated by the frameTransformServer device. If true, "/frameTransformServer" will appended to the port name prefix | - * | nws_thrift_port_prefix | - | string | - | "" | No | a prefix for the nws thrift rpc port name | - * | output_streaming_port_prefix | - | string | - | "" | No | a prefix for the output streaming port name | - * | streaming_enabled | - | bool | - | true | No | enable/disable the tf publishing on the streaming port | - * | period | | float | s | 0.010 | No | It affects the period of thread publishing transforms on the streaming port | + * Parameters required by this device are shown in class: FrameTransformGet_nws_yarpParamsParser * * \section FrameTransformGet_nwc_yarp_port_example Port names examples * Here follow some examples of port names obtained with different parameters configurations @@ -76,7 +70,8 @@ class FrameTransformGet_nws_yarp : public yarp::dev::DeviceDriver, public FrameTransformStorageGetRPC, public yarp::dev::WrapperSingle, - public yarp::os::PeriodicThread + public yarp::os::PeriodicThread, + public FrameTransformGet_nws_yarp_ParamsParser { public: diff --git a/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_ParamsParser.cpp b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_ParamsParser.cpp new file mode 100644 index 00000000000..4cc494734e1 --- /dev/null +++ b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_ParamsParser.cpp @@ -0,0 +1,213 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + + +// Generated by yarpDeviceParamParserGenerator (2.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 May 26 10:28:39 2025 + + +#include "FrameTransformGet_nws_yarp_ParamsParser.h" +#include +#include + +namespace { + YARP_LOG_COMPONENT(FrameTransformGet_nws_yarpParamsCOMPONENT, "yarp.device.FrameTransformGet_nws_yarp") +} + + +FrameTransformGet_nws_yarp_ParamsParser::FrameTransformGet_nws_yarp_ParamsParser() +{ +} + + +std::vector FrameTransformGet_nws_yarp_ParamsParser::getListOfParams() const +{ + std::vector params; + params.push_back("period"); + params.push_back("streaming_enabled"); + params.push_back("output_streaming_port_prefix"); + params.push_back("nws_thrift_port_prefix"); + params.push_back("default_config"); + return params; +} + + +bool FrameTransformGet_nws_yarp_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const +{ + if (paramName =="period") + { + if (m_period==true) paramValue = "true"; + else paramValue = "false"; + return true; + } + if (paramName =="streaming_enabled") + { + paramValue = m_streaming_enabled; + return true; + } + if (paramName =="output_streaming_port_prefix") + { + paramValue = m_output_streaming_port_prefix; + return true; + } + if (paramName =="nws_thrift_port_prefix") + { + if (m_nws_thrift_port_prefix==true) paramValue = "true"; + else paramValue = "false"; + return true; + } + if (paramName =="default_config") + { + paramValue = std::to_string(m_default_config); + return true; + } + + yError() <<"parameter '" << paramName << "' was not found"; + return false; + +} + + +std::string FrameTransformGet_nws_yarp_ParamsParser::getConfiguration() const +{ + //This is a sub-optimal solution. + //Ideally getConfiguration() should return all parameters but it is currently + //returning only user provided parameters (excluding default values) + //This behaviour will be fixed in the near future. + std::string s_cfg = m_provided_configuration; + return s_cfg; +} + +bool FrameTransformGet_nws_yarp_ParamsParser::parseParams(const yarp::os::Searchable & config) +{ + //Check for --help option + if (config.check("help")) + { + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << getDocumentationOfDeviceParams(); + } + + m_provided_configuration = config.toString(); + yarp::os::Property prop_check(m_provided_configuration.c_str()); + //Parser of parameter period + { + if (config.check("period")) + { + m_period = config.find("period").asBool(); + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'period' using value:" << m_period; + } + else + { + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period; + } + prop_check.unput("period"); + } + + //Parser of parameter streaming_enabled + { + if (config.check("streaming_enabled")) + { + m_streaming_enabled = config.find("streaming_enabled").asString(); + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'streaming_enabled' using value:" << m_streaming_enabled; + } + else + { + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'streaming_enabled' using DEFAULT value:" << m_streaming_enabled; + } + prop_check.unput("streaming_enabled"); + } + + //Parser of parameter output_streaming_port_prefix + { + if (config.check("output_streaming_port_prefix")) + { + m_output_streaming_port_prefix = config.find("output_streaming_port_prefix").asString(); + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'output_streaming_port_prefix' using value:" << m_output_streaming_port_prefix; + } + else + { + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'output_streaming_port_prefix' using DEFAULT value:" << m_output_streaming_port_prefix; + } + prop_check.unput("output_streaming_port_prefix"); + } + + //Parser of parameter nws_thrift_port_prefix + { + if (config.check("nws_thrift_port_prefix")) + { + m_nws_thrift_port_prefix = config.find("nws_thrift_port_prefix").asBool(); + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using value:" << m_nws_thrift_port_prefix; + } + else + { + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using DEFAULT value:" << m_nws_thrift_port_prefix; + } + prop_check.unput("nws_thrift_port_prefix"); + } + + //Parser of parameter default_config + { + if (config.check("default_config")) + { + m_default_config = config.find("default_config").asFloat32(); + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'default_config' using value:" << m_default_config; + } + else + { + yCInfo(FrameTransformGet_nws_yarpParamsCOMPONENT) << "Parameter 'default_config' using DEFAULT value:" << m_default_config; + } + prop_check.unput("default_config"); + } + + /* + //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(FrameTransformGet_nws_yarpParamsCOMPONENT) << "User asking for parameter: "<name <<" which is unknown to this parser!"; + extra_params_found = true; + } + else + { + yCWarning(FrameTransformGet_nws_yarpParamsCOMPONENT) << "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 FrameTransformGet_nws_yarp_ParamsParser::getDocumentationOfDeviceParams() const +{ + std::string doc; + doc = doc + std::string("\n=============================================\n"); + doc = doc + std::string("This is the help for device: FrameTransformGet_nws_yarp\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("'period': tells whether or not the nws is instanciated by the frameTransformServer device. If true, \"/frameTransformServer\" will appended to the port name prefix\n"); + doc = doc + std::string("'streaming_enabled': a prefix for the nws thrift rpc port name\n"); + doc = doc + std::string("'output_streaming_port_prefix': a prefix for the output streaming port name\n"); + doc = doc + std::string("'nws_thrift_port_prefix': enable/disable the tf publishing on the streaming port\n"); + doc = doc + std::string("'default_config': It affects the period of thread publishing transforms on the streaming port\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 frameTransformGet_nws_yarp --period true --streaming_enabled --output_streaming_port_prefix --nws_thrift_port_prefix true --default_config 0.010\n"; + doc = doc + std::string("Using only mandatory params:\n"); + doc = doc + " yarpdev --device frameTransformGet_nws_yarp\n"; + doc = doc + std::string("=============================================\n\n"); return doc; +} diff --git a/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_ParamsParser.h b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_ParamsParser.h new file mode 100644 index 00000000000..32eb9d0329b --- /dev/null +++ b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_ParamsParser.h @@ -0,0 +1,85 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + + +// Generated by yarpDeviceParamParserGenerator (2.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 May 26 10:28:39 2025 + + +#ifndef FRAMETRANSFORMGET_NWS_YARP_PARAMSPARSER_H +#define FRAMETRANSFORMGET_NWS_YARP_PARAMSPARSER_H + +#include +#include +#include +#include + +/** +* This class is the parameters parser for class FrameTransformGet_nws_yarp. +* +* These are the used parameters: +* | Group name | Parameter name | Type | Units | Default Value | Required | Description | Notes | +* |:----------:|:----------------------------:|:------:|:-----:|:-------------:|:--------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----:| +* | - | period | bool | - | true | 0 | tells whether or not the nws is instanciated by the frameTransformServer device. If true, \"/frameTransformServer\" will appended to the port name prefix | - | +* | - | streaming_enabled | string | - | - | 0 | a prefix for the nws thrift rpc port name | - | +* | - | output_streaming_port_prefix | string | - | - | 0 | a prefix for the output streaming port name | - | +* | - | nws_thrift_port_prefix | bool | - | true | 0 | enable/disable the tf publishing on the streaming port | - | +* | - | default_config | float | s | 0.010 | 0 | It affects the period of thread publishing transforms on the streaming port | - | +* +* The device can be launched by yarpdev using one of the following examples (with and without all optional parameters): +* \code{.unparsed} +* yarpdev --device frameTransformGet_nws_yarp --period true --streaming_enabled --output_streaming_port_prefix --nws_thrift_port_prefix true --default_config 0.010 +* \endcode +* +* \code{.unparsed} +* yarpdev --device frameTransformGet_nws_yarp +* \endcode +* +*/ + +class FrameTransformGet_nws_yarp_ParamsParser : public yarp::dev::IDeviceDriverParams +{ +public: + FrameTransformGet_nws_yarp_ParamsParser(); + ~FrameTransformGet_nws_yarp_ParamsParser() override = default; + +public: + const std::string m_device_classname = {"FrameTransformGet_nws_yarp"}; + const std::string m_device_name = {"frameTransformGet_nws_yarp"}; + bool m_parser_is_strict = false; + struct parser_version_type + { + int major = 2; + int minor = 0; + }; + const parser_version_type m_parser_version = {}; + + std::string m_provided_configuration; + + const std::string m_period_defaultValue = {"true"}; + const std::string m_streaming_enabled_defaultValue = {""}; + const std::string m_output_streaming_port_prefix_defaultValue = {""}; + const std::string m_nws_thrift_port_prefix_defaultValue = {"true"}; + const std::string m_default_config_defaultValue = {"0.010"}; + + bool m_period = {true}; + std::string m_streaming_enabled = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + std::string m_output_streaming_port_prefix = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + bool m_nws_thrift_port_prefix = {true}; + float m_default_config = {0.010}; + + bool parseParams(const yarp::os::Searchable & config) override; + std::string getDeviceClassName() const override { return m_device_classname; } + std::string getDeviceName() const override { return m_device_name; } + std::string getDocumentationOfDeviceParams() const override; + std::vector getListOfParams() const override; + bool getParamValue(const std::string& paramName, std::string& paramValue) const override; + std::string getConfiguration() const override; +}; + +#endif diff --git a/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_params.md b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_params.md new file mode 100644 index 00000000000..c90b0e33216 --- /dev/null +++ b/src/devices/networkWrappers/frameTransformGet_nws_yarp/FrameTransformGet_nws_yarp_params.md @@ -0,0 +1,5 @@ + * | | period | bool | - | true | No | tells whether or not the nws is instanciated by the frameTransformServer device. If true, "/frameTransformServer" will appended to the port name prefix | + * | | streaming_enabled | string | - | "" | No | a prefix for the nws thrift rpc port name | + * | | output_streaming_port_prefix | string | - | "" | No | a prefix for the output streaming port name | + * | | nws_thrift_port_prefix | bool | - | true | No | enable/disable the tf publishing on the streaming port | + * | | default_config | float | s | 0.010 | No | It affects the period of thread publishing transforms on the streaming port | diff --git a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/CMakeLists.txt b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/CMakeLists.txt index dc6ebfff23e..8871df89681 100644 --- a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/CMakeLists.txt +++ b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/CMakeLists.txt @@ -10,6 +10,7 @@ yarp_prepare_plugin(frameTransformSet_nwc_yarp EXTRA_CONFIG WRAPPER=frameTransformSet_nws_yarp DEFAULT ON + GENERATE_PARSER ) if(NOT SKIP_frameTransformSet_nwc_yarp) @@ -19,6 +20,8 @@ if(NOT SKIP_frameTransformSet_nwc_yarp) PRIVATE FrameTransformSet_nwc_yarp.cpp FrameTransformSet_nwc_yarp.h + FrameTransformSet_nwc_yarp_ParamsParser.cpp + FrameTransformSet_nwc_yarp_ParamsParser.h ) target_sources(yarp_frameTransformSet_nwc_yarp PRIVATE $) diff --git a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp.cpp b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp.cpp index ccc7c1dec5a..141bb8c5260 100644 --- a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp.cpp +++ b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp.cpp @@ -22,11 +22,8 @@ YARP_LOG_COMPONENT(FRAMETRANSFORMSETNWCYARP, "yarp.device.frameTransformSet_nwc_ bool FrameTransformSet_nwc_yarp::open(yarp::os::Searchable& config) { + if (!parseParams(config)) { return false; } - if (!yarp::os::NetworkBase::checkNetwork()) { - yCError(FRAMETRANSFORMSETNWCYARP,"Error! YARP Network is not initialized"); - return false; - } std::string prefix; //checking default config params bool default_config = true; diff --git a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp.h b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp.h index 3b66f3c3ce2..a7e79a0a362 100644 --- a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp.h +++ b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp.h @@ -15,6 +15,8 @@ #include #include +#include "FrameTransformSet_nwc_yarp_ParamsParser.h" + /** * @ingroup dev_impl_nwc_yarp * @@ -23,13 +25,7 @@ * \section FrameTransformSet_nwc_yarp_device_parameters Parameters * This device is paired with its server called FrameTransformSet_nws_yarp. * - * Parameters required by this device are: - * | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | - * |:----------------------------:|:-------------|:-------:|:------:|:--------------:|:------- -:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| - * | default-client | - | bool | - | true | No | tells whether or not the nwc is instantiated by the frameTransformClient device. If true, "/frameTransformClient" will appended to the port name prefix | - * | default-server | - | bool | - | true | No | tells whether or not the nws is instantiated by the frameTransformServer device. If true, "/frameTransformServer/frameTransformSet_nws_yarp" will appended to the port name prefix | - * | nwc_thrift_port_prefix | - | string | - | "" | No | a prefix for the nwc thrift rpc port name | - * | nws_thrift_port_prefix | - | string | - | "" | No | a prefix for the nws thrift rpc port name | + * Parameters required by this device are shown in class: FrameTransformSet_nwc_yarpParamsParser * * \section FrameTransformGet_nwc_yarp_port_example Port names examples * Here follow some examples of port names obtained with different parameters configurations @@ -69,7 +65,8 @@ class FrameTransformSet_nwc_yarp : public yarp::dev::DeviceDriver, - public yarp::dev::IFrameTransformStorageSet + public yarp::dev::IFrameTransformStorageSet, + public FrameTransformSet_nwc_yarp_ParamsParser { public: diff --git a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_ParamsParser.cpp b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_ParamsParser.cpp new file mode 100644 index 00000000000..fa937b462d5 --- /dev/null +++ b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_ParamsParser.cpp @@ -0,0 +1,192 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + + +// Generated by yarpDeviceParamParserGenerator (2.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 May 26 10:28:39 2025 + + +#include "FrameTransformSet_nwc_yarp_ParamsParser.h" +#include +#include + +namespace { + YARP_LOG_COMPONENT(FrameTransformSet_nwc_yarpParamsCOMPONENT, "yarp.device.FrameTransformSet_nwc_yarp") +} + + +FrameTransformSet_nwc_yarp_ParamsParser::FrameTransformSet_nwc_yarp_ParamsParser() +{ +} + + +std::vector FrameTransformSet_nwc_yarp_ParamsParser::getListOfParams() const +{ + std::vector params; + params.push_back("nws_thrift_port_prefix"); + params.push_back("nwc_thrift_port_prefix"); + params.push_back("default_server"); + params.push_back("default_client"); + return params; +} + + +bool FrameTransformSet_nwc_yarp_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const +{ + if (paramName =="nws_thrift_port_prefix") + { + if (m_nws_thrift_port_prefix==true) paramValue = "true"; + else paramValue = "false"; + return true; + } + if (paramName =="nwc_thrift_port_prefix") + { + if (m_nwc_thrift_port_prefix==true) paramValue = "true"; + else paramValue = "false"; + return true; + } + if (paramName =="default_server") + { + paramValue = m_default_server; + return true; + } + if (paramName =="default_client") + { + paramValue = m_default_client; + return true; + } + + yError() <<"parameter '" << paramName << "' was not found"; + return false; + +} + + +std::string FrameTransformSet_nwc_yarp_ParamsParser::getConfiguration() const +{ + //This is a sub-optimal solution. + //Ideally getConfiguration() should return all parameters but it is currently + //returning only user provided parameters (excluding default values) + //This behaviour will be fixed in the near future. + std::string s_cfg = m_provided_configuration; + return s_cfg; +} + +bool FrameTransformSet_nwc_yarp_ParamsParser::parseParams(const yarp::os::Searchable & config) +{ + //Check for --help option + if (config.check("help")) + { + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << getDocumentationOfDeviceParams(); + } + + m_provided_configuration = config.toString(); + yarp::os::Property prop_check(m_provided_configuration.c_str()); + //Parser of parameter nws_thrift_port_prefix + { + if (config.check("nws_thrift_port_prefix")) + { + m_nws_thrift_port_prefix = config.find("nws_thrift_port_prefix").asBool(); + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using value:" << m_nws_thrift_port_prefix; + } + else + { + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using DEFAULT value:" << m_nws_thrift_port_prefix; + } + prop_check.unput("nws_thrift_port_prefix"); + } + + //Parser of parameter nwc_thrift_port_prefix + { + if (config.check("nwc_thrift_port_prefix")) + { + m_nwc_thrift_port_prefix = config.find("nwc_thrift_port_prefix").asBool(); + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "Parameter 'nwc_thrift_port_prefix' using value:" << m_nwc_thrift_port_prefix; + } + else + { + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "Parameter 'nwc_thrift_port_prefix' using DEFAULT value:" << m_nwc_thrift_port_prefix; + } + prop_check.unput("nwc_thrift_port_prefix"); + } + + //Parser of parameter default_server + { + if (config.check("default_server")) + { + m_default_server = config.find("default_server").asString(); + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_server' using value:" << m_default_server; + } + else + { + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_server' using DEFAULT value:" << m_default_server; + } + prop_check.unput("default_server"); + } + + //Parser of parameter default_client + { + if (config.check("default_client")) + { + m_default_client = config.find("default_client").asString(); + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_client' using value:" << m_default_client; + } + else + { + yCInfo(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_client' using DEFAULT value:" << m_default_client; + } + prop_check.unput("default_client"); + } + + /* + //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(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "User asking for parameter: "<name <<" which is unknown to this parser!"; + extra_params_found = true; + } + else + { + yCWarning(FrameTransformSet_nwc_yarpParamsCOMPONENT) << "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 FrameTransformSet_nwc_yarp_ParamsParser::getDocumentationOfDeviceParams() const +{ + std::string doc; + doc = doc + std::string("\n=============================================\n"); + doc = doc + std::string("This is the help for device: FrameTransformSet_nwc_yarp\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("'nws_thrift_port_prefix': tells whether or not the nwc is instantiated by the frameTransformClient device. If true, \"/frameTransformClient\" will appended to the port name prefix\n"); + doc = doc + std::string("'nwc_thrift_port_prefix': tells whether or not the nws is instantiated by the frameTransformServer device. If true, \"/frameTransformServer/frameTransformSet_nws_yarp\" will appended to the port name prefix\n"); + doc = doc + std::string("'default_server': a prefix for the nwc thrift rpc port name\n"); + doc = doc + std::string("'default_client': a prefix for the nws thrift rpc port name\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 frameTransformSet_nwc_yarp --nws_thrift_port_prefix true --nwc_thrift_port_prefix true --default_server --default_client \n"; + doc = doc + std::string("Using only mandatory params:\n"); + doc = doc + " yarpdev --device frameTransformSet_nwc_yarp\n"; + doc = doc + std::string("=============================================\n\n"); return doc; +} diff --git a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_ParamsParser.h b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_ParamsParser.h new file mode 100644 index 00000000000..2ec52a5f7a5 --- /dev/null +++ b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_ParamsParser.h @@ -0,0 +1,82 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + + +// Generated by yarpDeviceParamParserGenerator (2.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 May 26 10:28:39 2025 + + +#ifndef FRAMETRANSFORMSET_NWC_YARP_PARAMSPARSER_H +#define FRAMETRANSFORMSET_NWC_YARP_PARAMSPARSER_H + +#include +#include +#include +#include + +/** +* This class is the parameters parser for class FrameTransformSet_nwc_yarp. +* +* These are the used parameters: +* | Group name | Parameter name | Type | Units | Default Value | Required | Description | Notes | +* |:----------:|:----------------------:|:------:|:-----:|:-------------:|:--------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----:| +* | - | nws_thrift_port_prefix | bool | - | true | 0 | tells whether or not the nwc is instantiated by the frameTransformClient device. If true, \"/frameTransformClient\" will appended to the port name prefix | - | +* | - | nwc_thrift_port_prefix | bool | - | true | 0 | tells whether or not the nws is instantiated by the frameTransformServer device. If true, \"/frameTransformServer/frameTransformSet_nws_yarp\" will appended to the port name prefix | - | +* | - | default_server | string | - | - | 0 | a prefix for the nwc thrift rpc port name | - | +* | - | default_client | string | - | - | 0 | a prefix for the nws thrift rpc port name | - | +* +* The device can be launched by yarpdev using one of the following examples (with and without all optional parameters): +* \code{.unparsed} +* yarpdev --device frameTransformSet_nwc_yarp --nws_thrift_port_prefix true --nwc_thrift_port_prefix true --default_server --default_client +* \endcode +* +* \code{.unparsed} +* yarpdev --device frameTransformSet_nwc_yarp +* \endcode +* +*/ + +class FrameTransformSet_nwc_yarp_ParamsParser : public yarp::dev::IDeviceDriverParams +{ +public: + FrameTransformSet_nwc_yarp_ParamsParser(); + ~FrameTransformSet_nwc_yarp_ParamsParser() override = default; + +public: + const std::string m_device_classname = {"FrameTransformSet_nwc_yarp"}; + const std::string m_device_name = {"frameTransformSet_nwc_yarp"}; + bool m_parser_is_strict = false; + struct parser_version_type + { + int major = 2; + int minor = 0; + }; + const parser_version_type m_parser_version = {}; + + std::string m_provided_configuration; + + const std::string m_nws_thrift_port_prefix_defaultValue = {"true"}; + const std::string m_nwc_thrift_port_prefix_defaultValue = {"true"}; + const std::string m_default_server_defaultValue = {""}; + const std::string m_default_client_defaultValue = {""}; + + bool m_nws_thrift_port_prefix = {true}; + bool m_nwc_thrift_port_prefix = {true}; + std::string m_default_server = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + std::string m_default_client = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + + bool parseParams(const yarp::os::Searchable & config) override; + std::string getDeviceClassName() const override { return m_device_classname; } + std::string getDeviceName() const override { return m_device_name; } + std::string getDocumentationOfDeviceParams() const override; + std::vector getListOfParams() const override; + bool getParamValue(const std::string& paramName, std::string& paramValue) const override; + std::string getConfiguration() const override; +}; + +#endif diff --git a/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_params.md b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_params.md new file mode 100644 index 00000000000..c4d7a0da730 --- /dev/null +++ b/src/devices/networkWrappers/frameTransformSet_nwc_yarp/FrameTransformSet_nwc_yarp_params.md @@ -0,0 +1,4 @@ + * | | nws_thrift_port_prefix | bool | - | true | No | tells whether or not the nwc is instantiated by the frameTransformClient device. If true, "/frameTransformClient" will appended to the port name prefix | + * | | nwc_thrift_port_prefix | bool | - | true | No | tells whether or not the nws is instantiated by the frameTransformServer device. If true, "/frameTransformServer/frameTransformSet_nws_yarp" will appended to the port name prefix | + * | | default_server | string | - | | No | a prefix for the nwc thrift rpc port name | + * | | default_client | string | - | | No | a prefix for the nws thrift rpc port name | diff --git a/src/devices/networkWrappers/frameTransformSet_nws_yarp/CMakeLists.txt b/src/devices/networkWrappers/frameTransformSet_nws_yarp/CMakeLists.txt index 583ac39dc69..5a7a0a5f4bb 100644 --- a/src/devices/networkWrappers/frameTransformSet_nws_yarp/CMakeLists.txt +++ b/src/devices/networkWrappers/frameTransformSet_nws_yarp/CMakeLists.txt @@ -10,6 +10,7 @@ yarp_prepare_plugin(frameTransformSet_nws_yarp EXTRA_CONFIG WRAPPER=frameTransformSet_nws_yarp DEFAULT ON + GENERATE_PARSER ) if(NOT SKIP_frameTransformSet_nws_yarp) @@ -19,6 +20,8 @@ if(NOT SKIP_frameTransformSet_nws_yarp) PRIVATE FrameTransformSet_nws_yarp.cpp FrameTransformSet_nws_yarp.h + FrameTransformSet_nws_yarp_ParamsParser.cpp + FrameTransformSet_nws_yarp_ParamsParser.h ) target_sources(yarp_frameTransformSet_nws_yarp PRIVATE $) diff --git a/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp.cpp b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp.cpp index 0cb16ce7fd8..f4fb0c4efb8 100644 --- a/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp.cpp +++ b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp.cpp @@ -22,10 +22,7 @@ YARP_LOG_COMPONENT(FRAMETRANSFORMSETNWSYARP, "yarp.device.frameTransformSet_nws_ bool FrameTransformSet_nws_yarp::open(yarp::os::Searchable& config) { - if (!yarp::os::NetworkBase::checkNetwork()) { - yCError(FRAMETRANSFORMSETNWSYARP,"Error! YARP Network is not initialized"); - return false; - } + if (!parseParams(config)) { return false; } std::string prefix; //checking default config param diff --git a/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp.h b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp.h index 4507acd93f3..fd928609351 100644 --- a/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp.h +++ b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp.h @@ -16,6 +16,8 @@ #include #include +#include "FrameTransformSet_nws_yarp_ParamsParser.h" + /** * @ingroup dev_impl_nws_yarp * @@ -24,11 +26,7 @@ * \section FrameTransformSet_nws_yarp_device_parameters Parameters * This device is paired with its server called FrameTransformSet_nwc_yarp. * - * Parameters required by this device are: - * | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | - * |:----------------------------:|:-----------------------:|:-------:|:--------------:|:--------------:|:------- -:|:-------------------------------------------------------------------------------------------------------------------------------------------------------:| - * | default-config | - | bool | - | true | No | tells whether or not the nws is instanciated by the frameTransformServer device. If true, "/frameTransformServer" will appended to the port name prefix | - * | nws_thrift_port_prefix | - | string | - | "" | No | a prefix for the nws thrift rpc port name | + * Parameters required by this device are shown in class: FrameTransformSet_nws_yarpParamsParser * * \section FrameTransformGet_nwc_yarp_port_example Port names examples * Here follow some examples of port names obtained with different parameters configurations @@ -57,7 +55,8 @@ class FrameTransformSet_nws_yarp : public yarp::dev::DeviceDriver, public FrameTransformStorageSetRPC, - public yarp::dev::WrapperSingle + public yarp::dev::WrapperSingle, + public FrameTransformSet_nws_yarp_ParamsParser { public: diff --git a/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_ParamsParser.cpp b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_ParamsParser.cpp new file mode 100644 index 00000000000..24d5af2cfbf --- /dev/null +++ b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_ParamsParser.cpp @@ -0,0 +1,149 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + + +// Generated by yarpDeviceParamParserGenerator (2.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 May 26 10:28:39 2025 + + +#include "FrameTransformSet_nws_yarp_ParamsParser.h" +#include +#include + +namespace { + YARP_LOG_COMPONENT(FrameTransformSet_nws_yarpParamsCOMPONENT, "yarp.device.FrameTransformSet_nws_yarp") +} + + +FrameTransformSet_nws_yarp_ParamsParser::FrameTransformSet_nws_yarp_ParamsParser() +{ +} + + +std::vector FrameTransformSet_nws_yarp_ParamsParser::getListOfParams() const +{ + std::vector params; + params.push_back("nws_thrift_port_prefix"); + params.push_back("default_config"); + return params; +} + + +bool FrameTransformSet_nws_yarp_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const +{ + if (paramName =="nws_thrift_port_prefix") + { + if (m_nws_thrift_port_prefix==true) paramValue = "true"; + else paramValue = "false"; + return true; + } + if (paramName =="default_config") + { + paramValue = m_default_config; + return true; + } + + yError() <<"parameter '" << paramName << "' was not found"; + return false; + +} + + +std::string FrameTransformSet_nws_yarp_ParamsParser::getConfiguration() const +{ + //This is a sub-optimal solution. + //Ideally getConfiguration() should return all parameters but it is currently + //returning only user provided parameters (excluding default values) + //This behaviour will be fixed in the near future. + std::string s_cfg = m_provided_configuration; + return s_cfg; +} + +bool FrameTransformSet_nws_yarp_ParamsParser::parseParams(const yarp::os::Searchable & config) +{ + //Check for --help option + if (config.check("help")) + { + yCInfo(FrameTransformSet_nws_yarpParamsCOMPONENT) << getDocumentationOfDeviceParams(); + } + + m_provided_configuration = config.toString(); + yarp::os::Property prop_check(m_provided_configuration.c_str()); + //Parser of parameter nws_thrift_port_prefix + { + if (config.check("nws_thrift_port_prefix")) + { + m_nws_thrift_port_prefix = config.find("nws_thrift_port_prefix").asBool(); + yCInfo(FrameTransformSet_nws_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using value:" << m_nws_thrift_port_prefix; + } + else + { + yCInfo(FrameTransformSet_nws_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using DEFAULT value:" << m_nws_thrift_port_prefix; + } + prop_check.unput("nws_thrift_port_prefix"); + } + + //Parser of parameter default_config + { + if (config.check("default_config")) + { + m_default_config = config.find("default_config").asString(); + yCInfo(FrameTransformSet_nws_yarpParamsCOMPONENT) << "Parameter 'default_config' using value:" << m_default_config; + } + else + { + yCInfo(FrameTransformSet_nws_yarpParamsCOMPONENT) << "Parameter 'default_config' using DEFAULT value:" << m_default_config; + } + prop_check.unput("default_config"); + } + + /* + //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(FrameTransformSet_nws_yarpParamsCOMPONENT) << "User asking for parameter: "<name <<" which is unknown to this parser!"; + extra_params_found = true; + } + else + { + yCWarning(FrameTransformSet_nws_yarpParamsCOMPONENT) << "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 FrameTransformSet_nws_yarp_ParamsParser::getDocumentationOfDeviceParams() const +{ + std::string doc; + doc = doc + std::string("\n=============================================\n"); + doc = doc + std::string("This is the help for device: FrameTransformSet_nws_yarp\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("'nws_thrift_port_prefix': tells whether or not the nws is instanciated by the frameTransformServer device. If true, \"/frameTransformServer\" will appended to the port name prefix\n"); + doc = doc + std::string("'default_config': a prefix for the nws thrift rpc port name\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 frameTransformSet_nws_yarp --nws_thrift_port_prefix true --default_config \n"; + doc = doc + std::string("Using only mandatory params:\n"); + doc = doc + " yarpdev --device frameTransformSet_nws_yarp\n"; + doc = doc + std::string("=============================================\n\n"); return doc; +} diff --git a/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_ParamsParser.h b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_ParamsParser.h new file mode 100644 index 00000000000..3c99805bbea --- /dev/null +++ b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_ParamsParser.h @@ -0,0 +1,76 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + + +// Generated by yarpDeviceParamParserGenerator (2.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 May 26 10:28:39 2025 + + +#ifndef FRAMETRANSFORMSET_NWS_YARP_PARAMSPARSER_H +#define FRAMETRANSFORMSET_NWS_YARP_PARAMSPARSER_H + +#include +#include +#include +#include + +/** +* This class is the parameters parser for class FrameTransformSet_nws_yarp. +* +* These are the used parameters: +* | Group name | Parameter name | Type | Units | Default Value | Required | Description | Notes | +* |:----------:|:----------------------:|:------:|:-----:|:-------------:|:--------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----:| +* | - | nws_thrift_port_prefix | bool | - | true | 0 | tells whether or not the nws is instanciated by the frameTransformServer device. If true, \"/frameTransformServer\" will appended to the port name prefix | - | +* | - | default_config | string | - | - | 0 | a prefix for the nws thrift rpc port name | - | +* +* The device can be launched by yarpdev using one of the following examples (with and without all optional parameters): +* \code{.unparsed} +* yarpdev --device frameTransformSet_nws_yarp --nws_thrift_port_prefix true --default_config +* \endcode +* +* \code{.unparsed} +* yarpdev --device frameTransformSet_nws_yarp +* \endcode +* +*/ + +class FrameTransformSet_nws_yarp_ParamsParser : public yarp::dev::IDeviceDriverParams +{ +public: + FrameTransformSet_nws_yarp_ParamsParser(); + ~FrameTransformSet_nws_yarp_ParamsParser() override = default; + +public: + const std::string m_device_classname = {"FrameTransformSet_nws_yarp"}; + const std::string m_device_name = {"frameTransformSet_nws_yarp"}; + bool m_parser_is_strict = false; + struct parser_version_type + { + int major = 2; + int minor = 0; + }; + const parser_version_type m_parser_version = {}; + + std::string m_provided_configuration; + + const std::string m_nws_thrift_port_prefix_defaultValue = {"true"}; + const std::string m_default_config_defaultValue = {""}; + + bool m_nws_thrift_port_prefix = {true}; + std::string m_default_config = {}; //This default value of this string is an empty string. It is highly recommended to provide a suggested value also for optional string parameters. + + bool parseParams(const yarp::os::Searchable & config) override; + std::string getDeviceClassName() const override { return m_device_classname; } + std::string getDeviceName() const override { return m_device_name; } + std::string getDocumentationOfDeviceParams() const override; + std::vector getListOfParams() const override; + bool getParamValue(const std::string& paramName, std::string& paramValue) const override; + std::string getConfiguration() const override; +}; + +#endif diff --git a/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_params.md b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_params.md new file mode 100644 index 00000000000..46adb215a56 --- /dev/null +++ b/src/devices/networkWrappers/frameTransformSet_nws_yarp/FrameTransformSet_nws_yarp_params.md @@ -0,0 +1,2 @@ + * | | nws_thrift_port_prefix | bool | - | true | No | tells whether or not the nws is instanciated by the frameTransformServer device. If true, "/frameTransformServer" will appended to the port name prefix | + * | | default_config | string | - | | No | a prefix for the nws thrift rpc port name |