Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 $<TARGET_OBJECTS:frameTransformStorageMsgs>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")){
Expand Down Expand Up @@ -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();
}
Expand All @@ -145,7 +139,7 @@ bool FrameTransformGet_nwc_yarp::close()

ReturnValue FrameTransformGet_nwc_yarp::getTransforms(std::vector<yarp::math::FrameTransform>& transforms) const
{
if (!m_streaming_port_enabled)
if (!m_streaming_enabled)
{
return_getAllTransforms retrievedFromRPC = m_frameTransformStorageGetRPC.getTransformsRPC();
if(!retrievedFromRPC.retvalue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <yarp/dev/DeviceDriver.h>
#include <yarp/dev/IFrameTransformStorage.h>


#include <FrameTransformStorageGetRPC.h>
#include "FrameTransformGet_nwc_yarp_ParamsParser.h"

/**
* @ingroup dev_impl_nwc_yarp
Expand All @@ -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
Expand Down Expand Up @@ -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<return_getAllTransforms>
{
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <yarp/os/LogStream.h>
#include <yarp/os/Value.h>

namespace {
YARP_LOG_COMPONENT(FrameTransformGet_nwc_yarpParamsCOMPONENT, "yarp.device.FrameTransformGet_nwc_yarp")
}


FrameTransformGet_nwc_yarp_ParamsParser::FrameTransformGet_nwc_yarp_ParamsParser()
{
}


std::vector<std::string> FrameTransformGet_nwc_yarp_ParamsParser::getListOfParams() const
{
std::vector<std::string> 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: "<<it->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 <optional_value> --nws_thrift_port_prefix <optional_value> --nwc_thrift_port_prefix <optional_value> --default_server <optional_value> --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;
}
Loading
Loading