diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/CMakeLists.txt b/source/RobotAPI/libraries/RobotAPIComponentPlugins/CMakeLists.txt index 6567872ebd97ab3016b3af816f2048d473040464..444d6e770fa746c6924a1341d62651ecd4d1a953 100644 --- a/source/RobotAPI/libraries/RobotAPIComponentPlugins/CMakeLists.txt +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/CMakeLists.txt @@ -21,6 +21,7 @@ set(LIB_FILES TrajectoryPlayerComponentPlugin.cpp CartesianPositionControlComponentPlugin.cpp NaturalIKComponentPlugin.cpp + HandUnitComponentPlugin.cpp ) set(LIB_HEADERS RobotStateComponentPlugin.h @@ -34,6 +35,7 @@ set(LIB_HEADERS TrajectoryPlayerComponentPlugin.h CartesianPositionControlComponentPlugin.h NaturalIKComponentPlugin.h + HandUnitComponentPlugin.h ) armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}") diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HandUnitComponentPlugin.cpp b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HandUnitComponentPlugin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c99b6a9c2dafb560e00e86c28eee0108b650c888 --- /dev/null +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HandUnitComponentPlugin.cpp @@ -0,0 +1,54 @@ +#include "HandUnitComponentPlugin.h" + +namespace armarx +{ + namespace plugins + { + + void HandUnitComponentPlugin::preOnInitComponent() + { + parent<Component>().usingProxyFromProperty(PROPERTY_NAME); + } + + void HandUnitComponentPlugin::preOnConnectComponent() + { + parent<Component>().getProxyFromProperty(_handUnit, PROPERTY_NAME); + } + + void HandUnitComponentPlugin::postCreatePropertyDefinitions(armarx::PropertyDefinitionsPtr& properties) + { + if (!properties->hasDefinition(PROPERTY_NAME)) + { + properties->defineOptionalProperty<std::string>( + PROPERTY_NAME, + "HandUnit", + "Name of the HandUnit"); + } + } + + HandUnitInterfacePrx HandUnitComponentPlugin::getHandUnit() + { + return _handUnit; + } + + + } +} + +namespace armarx +{ + + HandUnitComponentPluginUser::HandUnitComponentPluginUser() + { + addPlugin(plugin); + } + + HandUnitInterfacePrx HandUnitComponentPluginUser::getHandUnit() + { + return plugin->getHandUnit(); + } + + +} + + diff --git a/source/RobotAPI/libraries/RobotAPIComponentPlugins/HandUnitComponentPlugin.h b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HandUnitComponentPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..4cd3593cb95abd83e023e8aa5642b68e23bea3fb --- /dev/null +++ b/source/RobotAPI/libraries/RobotAPIComponentPlugins/HandUnitComponentPlugin.h @@ -0,0 +1,58 @@ +#pragma once + +#include <ArmarXCore/core/Component.h> +#include <RobotAPI/interface/units/HandUnitInterface.h> + + +namespace armarx +{ + namespace plugins + { + + class HandUnitComponentPlugin : public ComponentPlugin + { + public: + using ComponentPlugin::ComponentPlugin; + + void preOnInitComponent() override; + + void preOnConnectComponent() override; + + void postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties) override; + + HandUnitInterfacePrx getHandUnit(); + + private: + static constexpr const char* PROPERTY_NAME = "HandUnitName"; + HandUnitInterfacePrx _handUnit; + }; + + } +} + +namespace armarx +{ + /** + * @brief Provides a ready-to-use HandUnit. + */ + class HandUnitComponentPluginUser : virtual public ManagedIceObject + { + public: + HandUnitComponentPluginUser(); + HandUnitInterfacePrx getHandUnit(); + + private: + armarx::plugins::HandUnitComponentPlugin* plugin = nullptr; + }; + +} + + +namespace armarx +{ + namespace plugins + { + // Legacy typedef. + using HandUnitComponentPluginUser = armarx::HandUnitComponentPluginUser; + } +}