From 3719cc126c5133a6465b856f7b53be101bc7659f Mon Sep 17 00:00:00 2001 From: Raphael Grimm <raphael.grimm@kit.edu> Date: Thu, 4 Jun 2020 08:55:06 +0200 Subject: [PATCH] Improve RobotStateComponentPlugin so it can be used in gui plugins --- .../RobotStateComponentPlugin.cpp | 21 +++++++++++++++++-- .../RobotStateComponentPlugin.h | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotStateComponentPlugin.cpp b/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotStateComponentPlugin.cpp index c54454585..3f28f11c8 100644 --- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotStateComponentPlugin.cpp +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotStateComponentPlugin.cpp @@ -199,9 +199,14 @@ namespace armarx::plugins void RobotStateComponentPlugin::preOnInitComponent() { + if (!_robotStateComponent && _robotStateComponentName.empty()) + { + parent<Component>().getProperty(_robotStateComponentName, makePropertyName(_propertyName)); + } + if (!_robotStateComponent) { - parent<Component>().usingProxyFromProperty(makePropertyName(_propertyName)); + parent<Component>().usingProxy(_robotStateComponentName); } } @@ -209,7 +214,7 @@ namespace armarx::plugins { if (!_robotStateComponent) { - parent<Component>().getProxyFromProperty(_robotStateComponent, makePropertyName(_propertyName)); + parent<Component>().getProxy(_robotStateComponent, _robotStateComponentName); } } @@ -242,6 +247,18 @@ namespace armarx::plugins ARMARX_CHECK_NOT_NULL(node) << "No tcp configured for the robot "; return SimpleDiffIK::CalculateReachability(targets, initialJV, rns, node, params); } + + void RobotStateComponentPlugin::setRobotStateComponentName(const std::string& name) + { + ARMARX_CHECK_NOT_EMPTY(name); + ARMARX_CHECK_EMPTY(_robotStateComponentName); + _robotStateComponentName = name; + } + + const std::string& RobotStateComponentPlugin::getRobotStateComponentName() const + { + return _robotStateComponentName; + } } namespace armarx diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotStateComponentPlugin.h b/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotStateComponentPlugin.h index a338957d1..25ca57fff 100644 --- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotStateComponentPlugin.h +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/RobotStateComponentPlugin.h @@ -53,6 +53,8 @@ namespace armarx::plugins struct RobotData; using ComponentPlugin::ComponentPlugin; + void setRobotStateComponentName(const std::string& name); + const std::string& getRobotStateComponentName() const; //get / add public: bool hasRobot(const std::string& id) const; @@ -137,6 +139,7 @@ namespace armarx::plugins //data public: static constexpr auto _propertyName = "RemoteStateComponentName"; + std::string _robotStateComponentName; RobotStateComponentInterfacePrx _robotStateComponent; mutable std::recursive_mutex _robotsMutex; std::map<std::string, RobotData> _robots; -- GitLab