From 508d453ad738336c7f0e7391954e2a388e72cc94 Mon Sep 17 00:00:00 2001 From: Pascal Weiner <pascal.weiner@kit.edu> Date: Thu, 4 Feb 2021 09:54:26 +0100 Subject: [PATCH] Add data streaming to RobotUnitComponentPlugin --- .../RobotAPIComponentPlugins/CMakeLists.txt | 1 + .../RobotUnitComponentPlugin.cpp | 19 +++++++++++++++++++ .../RobotUnitComponentPlugin.h | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/CMakeLists.txt b/source/RobotAPI/libraries/RobotAPIComponentPlugins/CMakeLists.txt index 3c9bbe17d..8e61ccd83 100644 --- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/CMakeLists.txt +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/CMakeLists.txt @@ -8,6 +8,7 @@ set(LIBS DebugDrawer diffik RobotStatechartHelpers + RobotUnitDataStreamingReceiver ) set(LIB_FILES diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.cpp b/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.cpp index 20c957ef7..54642a237 100644 --- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.cpp +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.cpp @@ -2,6 +2,15 @@ namespace armarx::plugins { + RobotUnitDataStreamingReceiverPtr + RobotUnitComponentPlugin::startDataSatreming( + const RobotUnitDataStreaming::Config& cfg) + { + //ok to create smart ptr from parent, since ice handels this + return make_shared<RobotUnitDataStreamingReceiver>( + &parent(), getRobotUnit(), cfg); + } + void RobotUnitComponentPlugin::postOnDisconnectComponent() { if (!_ctrls.empty()) @@ -19,6 +28,16 @@ namespace armarx::plugins bool doManageController) { ARMARX_CHECK_NOT_NULL(_robotUnit); + ARMARX_INFO << ARMARX_STREAM_PRINTER + { + out << "creating "; + if (doManageController) + { + out << "and managing "; + } + out << " controller '" << instanceName + << "' of class '" << instanceName << "'"; + }; const auto prx = _robotUnit->createOrReplaceNJointController(className, instanceName, config); ARMARX_CHECK_NOT_NULL(prx); if (doManageController) diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.h b/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.h index e72b5982c..7ba7dc09e 100644 --- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.h +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.h @@ -2,6 +2,7 @@ #include <ArmarXCore/core/Component.h> #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h> +#include <RobotAPI/libraries/RobotUnitDataStreamingReceiver/RobotUnitDataStreamingReceiver.h> namespace armarx @@ -28,6 +29,8 @@ namespace armarx void deactivate(); + //controllers + public: template<class PrxT> PrxT createNJointController(const std::string& className, const std::string& instanceName, @@ -51,6 +54,11 @@ namespace armarx bool doManageController = true); void manageController(const NJointControllerInterfacePrx& ctrl); void manageController(const std::string& ctrl); + + //datastreaming + public: + RobotUnitDataStreamingReceiverPtr startDataSatreming(const RobotUnitDataStreaming::Config& cfg); + private: static constexpr const char* PROPERTY_NAME = "RobotUnitName"; RobotUnitInterfacePrx _robotUnit; -- GitLab