From f32bf85e3139e2e3a636533c63c658179e474f1d Mon Sep 17 00:00:00 2001 From: elandini84 <62991576+elandini84@users.noreply.github.com> Date: Wed, 30 Jun 2021 17:02:01 +0200 Subject: [PATCH 1/3] CMakeRC integration first test Added support for CMakeRC library in YARP. Tests with frameTransformClient. Everything seems to work as expected. --- .../frameTransformClient/CMakeLists.txt | 19 ++++- .../frameTransformClient.cpp | 16 ++++- .../robotinterface_xml/ftc_full_ros.xml | 69 +++++++++++++++++++ .../robotinterface_xml/ftc_local_only.xml | 9 +++ .../robotinterface_xml/ftc_pub_ros.xml | 23 +++++++ .../robotinterface_xml/ftc_pub_yarp_only.xml | 15 ++++ .../robotinterface_xml/ftc_ros.xml | 50 ++++++++++++++ .../robotinterface_xml/ftc_sub_ros.xml | 28 ++++++++ .../robotinterface_xml/ftc_sub_yarp_only.xml | 21 ++++++ .../robotinterface_xml/ftc_yarp_only.xml | 35 ++++++++++ .../ftc_yarp_only_single_client.xml | 22 ++++++ 11 files changed, 303 insertions(+), 4 deletions(-) create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_full_ros.xml create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_local_only.xml create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_pub_ros.xml create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_pub_yarp_only.xml create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_ros.xml create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_sub_ros.xml create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_sub_yarp_only.xml create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_yarp_only.xml create mode 100644 src/devices/frameTransformClient/robotinterface_xml/ftc_yarp_only_single_client.xml diff --git a/src/devices/frameTransformClient/CMakeLists.txt b/src/devices/frameTransformClient/CMakeLists.txt index 6b34adfb633..641c65d60f0 100644 --- a/src/devices/frameTransformClient/CMakeLists.txt +++ b/src/devices/frameTransformClient/CMakeLists.txt @@ -4,6 +4,22 @@ # This software may be modified and distributed under the terms of the # BSD-3-Clause license. See the accompanying LICENSE file for details. +include(CMakeRC) + +cmrc_add_resource_library(frameTransformRobotInterface + NAMESPACE frameTransformRobotInterface + WHENCE robotinterface_xml + PREFIX config_xml + robotinterface_xml/ftc_full_ros.xml + robotinterface_xml/ftc_pub_ros.xml + robotinterface_xml/ftc_ros.xml + robotinterface_xml/ftc_sub_ros.xml + robotinterface_xml/ftc_pub_yarp_only.xml + robotinterface_xml/ftc_sub_yarp_only.xml + robotinterface_xml/ftc_yarp_only.xml + robotinterface_xml/ftc_yarp_only_single_client.xml + robotinterface_xml/ftc_local_only.xml) + yarp_prepare_plugin(frameTransformClient CATEGORY device TYPE FrameTransformClient @@ -24,7 +40,8 @@ if(NOT SKIP_frameTransformClient) YARP::YARP_sig YARP::YARP_dev YARP::YARP_math - YARP::YARP_robotinterface) + YARP::YARP_robotinterface + frameTransformRobotInterface) list(APPEND YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS YARP_os YARP_sig YARP_dev diff --git a/src/devices/frameTransformClient/frameTransformClient.cpp b/src/devices/frameTransformClient/frameTransformClient.cpp index 39362ca2c61..df993efddc5 100644 --- a/src/devices/frameTransformClient/frameTransformClient.cpp +++ b/src/devices/frameTransformClient/frameTransformClient.cpp @@ -23,6 +23,9 @@ #include #include +#include +CMRC_DECLARE(frameTransformRobotInterface); + /*! \file FrameTransformClient.cpp */ //example: yarpdev --device frameTransformClient --local /transformClient --remote /transformServer @@ -231,16 +234,23 @@ bool FrameTransformClient::open(yarp::os::Searchable &config) yarp::os::Property cfg; cfg.fromString(config.toString()); - string configuration_to_open; - if(cfg.check("filexml_option")) { configuration_to_open=cfg.find("filexml_option").toString();} + string configuration_to_open=""; + string innerFilePath="config_xml/ftc_local_only.xml"; + auto fs = cmrc::frameTransformRobotInterface::get_filesystem(); + if(cfg.check("filexml_option")) { innerFilePath="config_xml/"+cfg.find("filexml_option").toString();} cfg.unput("filexml_option"); + auto xmlFile = fs.open(innerFilePath); + for(auto& lemma : xmlFile) + { + configuration_to_open += lemma; + } string m_local_rpcUser = "/ftClient/rpc"; if (cfg.check("local_rpc")) { m_local_rpcUser=cfg.find("local_rpc").toString();} cfg.unput("local_rpc"); yarp::robotinterface::experimental::XMLReader reader; - yarp::robotinterface::experimental::XMLReaderResult result = reader.getRobotFromFile(configuration_to_open, cfg); + yarp::robotinterface::experimental::XMLReaderResult result = reader.getRobotFromString(configuration_to_open, cfg); yCAssert(FRAMETRANSFORMCLIENT, result.parsingIsSuccessful); m_robot = std::move(result.robot); // FIXME std::move non serve diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_full_ros.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_full_ros.xml new file mode 100644 index 00000000000..dae15c33b7f --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_full_ros.xml @@ -0,0 +1,69 @@ + + + + + + + + /frameTransformSet/clientRPC + /frameTransformSet/serverRPC + + + /frameTransformGet/clientRPC + /frameTransformGet/serverRPC + + + + + 0.01 + 0.1 + 1 + + + /tf + /tf_static + /tfNodeSet + + + + + 0.01 + 0.1 + + + /tf + /tf_static + /tfNodeGet + + + + + + + ftc_mpxGet + + + + + + + + + ftc_storage + ftSet_nwc_yarp + ftSet_nwc_ros + + + + + + + + ftGet_nwc_yarp + ftGet_nwc_ros + + + + + + diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_local_only.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_local_only.xml new file mode 100644 index 00000000000..eb8ce19b5b6 --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_local_only.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_pub_ros.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_pub_ros.xml new file mode 100644 index 00000000000..230cea8ee59 --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_pub_ros.xml @@ -0,0 +1,23 @@ + + + + + + + + + 0.01 + 0.1 + 1 + + + /tf + /tf_static + /tfNodeSet + + + + + + + diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_pub_yarp_only.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_pub_yarp_only.xml new file mode 100644 index 00000000000..d22171070fa --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_pub_yarp_only.xml @@ -0,0 +1,15 @@ + + + + + + + + /frameTransformSet/clientRPC + /frameTransformSet/serverRPC + + + + + + diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_ros.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_ros.xml new file mode 100644 index 00000000000..25dbf8dc595 --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_ros.xml @@ -0,0 +1,50 @@ + + + + + + + + + 0.01 + 0.1 + 1 + + + /tf + /tf_static + /tfNodeSet + + + + + 0.01 + 0.1 + + + /tf + /tf_static + /tfNodeGet + + + + + + + ftGet_nwc_ros + + + + + + + + + ftc_storage + ftSet_nwc_ros + + + + + + diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_sub_ros.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_sub_ros.xml new file mode 100644 index 00000000000..66d03b2714e --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_sub_ros.xml @@ -0,0 +1,28 @@ + + + + + + + + + 0.01 + 0.1 + + + /tf + /tf_static + /tfNodeGet + + + + + + + ftGet_nwc_ros + + + + + + diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_sub_yarp_only.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_sub_yarp_only.xml new file mode 100644 index 00000000000..d284c981ba6 --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_sub_yarp_only.xml @@ -0,0 +1,21 @@ + + + + + + + + /frameTransformGet/clientRPC + /frameTransformGet/serverRPC + + + + + + ftGet_nwc_yarp + + + + + + diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_yarp_only.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_yarp_only.xml new file mode 100644 index 00000000000..9f62ce5b64b --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_yarp_only.xml @@ -0,0 +1,35 @@ + + + + + + + + /frameTransformSet/clientRPC + /frameTransformSet/serverRPC + + + /frameTransformGet/clientRPC + /frameTransformGet/serverRPC + + + + + + ftGet_nwc_yarp + + + + + + + + + ftc_storage + ftSet_nwc_yarp + + + + + + diff --git a/src/devices/frameTransformClient/robotinterface_xml/ftc_yarp_only_single_client.xml b/src/devices/frameTransformClient/robotinterface_xml/ftc_yarp_only_single_client.xml new file mode 100644 index 00000000000..04abd15d331 --- /dev/null +++ b/src/devices/frameTransformClient/robotinterface_xml/ftc_yarp_only_single_client.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + /frameTransformSet/rpc + + + + ftc_storage + + + + + + From 185055bb0180309948c1a474f7d7e6b327f41732 Mon Sep 17 00:00:00 2001 From: elandini84 <62991576+elandini84@users.noreply.github.com> Date: Wed, 30 Jun 2021 17:38:48 +0200 Subject: [PATCH 2/3] CMakeRC static library workaround --- src/devices/frameTransformClient/CMakeLists.txt | 9 +++++---- .../frameTransformClient/frameTransformClient.cpp | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/devices/frameTransformClient/CMakeLists.txt b/src/devices/frameTransformClient/CMakeLists.txt index 641c65d60f0..538556d9bda 100644 --- a/src/devices/frameTransformClient/CMakeLists.txt +++ b/src/devices/frameTransformClient/CMakeLists.txt @@ -6,8 +6,8 @@ include(CMakeRC) -cmrc_add_resource_library(frameTransformRobotInterface - NAMESPACE frameTransformRobotInterface +cmrc_add_resource_library(frameTransformRC + NAMESPACE frameTransformRC WHENCE robotinterface_xml PREFIX config_xml robotinterface_xml/ftc_full_ros.xml @@ -40,8 +40,9 @@ if(NOT SKIP_frameTransformClient) YARP::YARP_sig YARP::YARP_dev YARP::YARP_math - YARP::YARP_robotinterface - frameTransformRobotInterface) + YARP::YARP_robotinterface) + target_sources(yarp_frameTransformClient PRIVATE $) + target_include_directories(yarp_frameTransformClient PRIVATE $) list(APPEND YARP_${YARP_PLUGIN_MASTER}_PRIVATE_DEPS YARP_os YARP_sig YARP_dev diff --git a/src/devices/frameTransformClient/frameTransformClient.cpp b/src/devices/frameTransformClient/frameTransformClient.cpp index df993efddc5..500d0d5768a 100644 --- a/src/devices/frameTransformClient/frameTransformClient.cpp +++ b/src/devices/frameTransformClient/frameTransformClient.cpp @@ -24,7 +24,7 @@ #include #include -CMRC_DECLARE(frameTransformRobotInterface); +CMRC_DECLARE(frameTransformRC); /*! \file FrameTransformClient.cpp */ @@ -236,7 +236,7 @@ bool FrameTransformClient::open(yarp::os::Searchable &config) string configuration_to_open=""; string innerFilePath="config_xml/ftc_local_only.xml"; - auto fs = cmrc::frameTransformRobotInterface::get_filesystem(); + auto fs = cmrc::frameTransformRC::get_filesystem(); if(cfg.check("filexml_option")) { innerFilePath="config_xml/"+cfg.find("filexml_option").toString();} cfg.unput("filexml_option"); auto xmlFile = fs.open(innerFilePath); From 5ed3965ab62fe04a0cfc030e211a15398d40a793 Mon Sep 17 00:00:00 2001 From: elandini84 <62991576+elandini84@users.noreply.github.com> Date: Thu, 1 Jul 2021 08:41:59 +0200 Subject: [PATCH 3/3] Clang-tidy issues addressed --- src/devices/frameTransformClient/frameTransformClient.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/frameTransformClient/frameTransformClient.cpp b/src/devices/frameTransformClient/frameTransformClient.cpp index 500d0d5768a..5877c40cb03 100644 --- a/src/devices/frameTransformClient/frameTransformClient.cpp +++ b/src/devices/frameTransformClient/frameTransformClient.cpp @@ -234,13 +234,13 @@ bool FrameTransformClient::open(yarp::os::Searchable &config) yarp::os::Property cfg; cfg.fromString(config.toString()); - string configuration_to_open=""; + string configuration_to_open; string innerFilePath="config_xml/ftc_local_only.xml"; auto fs = cmrc::frameTransformRC::get_filesystem(); if(cfg.check("filexml_option")) { innerFilePath="config_xml/"+cfg.find("filexml_option").toString();} cfg.unput("filexml_option"); auto xmlFile = fs.open(innerFilePath); - for(auto& lemma : xmlFile) + for(const auto& lemma : xmlFile) { configuration_to_open += lemma; }