diff --git a/source/RobotAPI/interface/units/HandUnitInterface.ice b/source/RobotAPI/interface/units/HandUnitInterface.ice index 524aa2dea69c0ef58387530b7b91421248fd6f27..6e1e94a815b3101254fd01143a5ce37a7791de74 100644 --- a/source/RobotAPI/interface/units/HandUnitInterface.ice +++ b/source/RobotAPI/interface/units/HandUnitInterface.ice @@ -30,6 +30,8 @@ #include <Core/interface/core/UserException.ice> #include <Core/interface/core/BasicTypes.ice> #include <Core/interface/observers/VariantContainers.ice> +#include <Core/interface/observers/ObserverInterface.ice> + module armarx { @@ -43,11 +45,12 @@ module armarx NameValueMap getPreshapeJointValues(string preshapeName); }; - interface HandUnitListener + interface HandUnitListener extends armarx::ObserverInterface { - void reportHandClosed(); - void reportHandOpened(); - void reportHandPreshaped(); + void reportHandClosed(bool isLeftHand); + void reportHandOpened(bool isLeftHand); + void reportHandPreshaped(bool isLeftHand); + void reportNewHandShapeName(bool isLeftHand, string handShapeName); }; }; diff --git a/source/RobotAPI/robotstate/remote/CMakeLists.txt b/source/RobotAPI/robotstate/remote/CMakeLists.txt index e2467fb00728633d76cc178e089e80d42b0f90e0..3c2fe56ef0dfcd8179643d1ef6bfd4bd9fcb8c35 100644 --- a/source/RobotAPI/robotstate/remote/CMakeLists.txt +++ b/source/RobotAPI/robotstate/remote/CMakeLists.txt @@ -1,5 +1,5 @@ -armarx_set_target("Core Library: ArmarXCoreRemoteRobot") +armarx_set_target("Core Library: RobotAPIRemoteRobot") find_package(Eigen3 QUIET) if (NOT Simox_FOUND) find_package(Simox 2.3.0 QUIET) diff --git a/source/RobotAPI/robotstate/remote/LinkedPose.cpp b/source/RobotAPI/robotstate/remote/LinkedPose.cpp index 23de4ee3ea5280558a126b45779cada9c132e5c0..fb57250f64aebf59cbd0db39c64a071b60ef4cc4 100644 --- a/source/RobotAPI/robotstate/remote/LinkedPose.cpp +++ b/source/RobotAPI/robotstate/remote/LinkedPose.cpp @@ -158,6 +158,8 @@ namespace armarx { void LinkedVector3::changeFrame(const std::string &newFrame, const Ice::Current &c) { + ARMARX_WARNING_S << "This function doesn't work!"; + if(newFrame == frame) return; diff --git a/source/RobotAPI/units/CMakeLists.txt b/source/RobotAPI/units/CMakeLists.txt index fd4a6fda6ed0eee68f165b88c9f6c7510ef8893c..0164bfeccee201feabbaae3a2da9ef9e4ddb8ec7 100644 --- a/source/RobotAPI/units/CMakeLists.txt +++ b/source/RobotAPI/units/CMakeLists.txt @@ -37,6 +37,7 @@ set(LIB_HEADERS TCPControlUnitObserver.h HandUnit.h + HandUnitObserver.h HardwareUnit.h KinematicUnit.h KinematicUnitSimulation.h @@ -58,6 +59,7 @@ set(LIB_FILES TCPControlUnitObserver.cpp HandUnit.cpp + HandUnitObserver.cpp HardwareUnit.cpp KinematicUnit.cpp KinematicUnitSimulation.cpp diff --git a/source/RobotAPI/units/HandUnitObserver.cpp b/source/RobotAPI/units/HandUnitObserver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cdb899d599f314c45bc75c8c8019c8339d6cf668 --- /dev/null +++ b/source/RobotAPI/units/HandUnitObserver.cpp @@ -0,0 +1,121 @@ +#include "HandUnitObserver.h" + + +#include <Core/observers/checks/ConditionCheckEquals.h> +#include <Core/observers/checks/ConditionCheckUpdated.h> + + + + +using namespace armarx; + + +void HandUnitObserver::onInitObserver() +{ + usingTopic("LeftHandState"); + usingTopic("RightHandState"); + + offerChannel("leftHand", "Gives information about the state of the left robot hand."); + offerDataField("leftHand", "isOpen", VariantType::Bool, "Is true when the hand is open, false if not."); + setDataField("leftHand", "isOpen", false); + offerDataField("leftHand", "isClosed", VariantType::Bool, "Is true when the hand is closed, false if not."); + setDataField("leftHand", "isClosed", false); + offerDataField("leftHand", "shapeName", VariantType::String, "Contains the name of the current hand shape."); + setDataField("leftHand", "shapeName", "unknown"); + updateChannel("leftHand"); + + offerChannel("rightHand", "Gives information about the state of the right robot hand."); + offerDataField("rightHand", "isOpen", VariantType::Bool, "Is true when the hand is open, false if not."); + setDataField("rightHand", "isOpen", false); + offerDataField("rightHand", "isClosed", VariantType::Bool, "Is true when the hand is closed, false if not."); + setDataField("rightHand", "isClosed", false); + offerDataField("rightHand", "shapeName", VariantType::String, "Contains the name of the current hand shape."); + setDataField("rightHand", "shapeName", "unknown"); + updateChannel("rightHand"); + + offerConditionCheck("equals", new armarx::ConditionCheckEquals()); + offerConditionCheck("updated", new armarx::ConditionCheckUpdated()); +} + + + +void HandUnitObserver::onConnectObserver() +{ + +} + + + +void HandUnitObserver::onExitObserver() +{ + +} + + + +void HandUnitObserver::reportHandClosed(bool isLeftHand, const Ice::Current&) +{ + if (isLeftHand) + { + setDataField("leftHand", "isOpen", false); + setDataField("leftHand", "isClosed", true); + updateChannel("leftHand"); + } + else + { + setDataField("rightHand", "isOpen", false); + setDataField("rightHand", "isClosed", true); + updateChannel("rightHand"); + } +} + + + +void HandUnitObserver::reportHandOpened(bool isLeftHand, const Ice::Current&) +{ + if (isLeftHand) + { + setDataField("leftHand", "isOpen", true); + setDataField("leftHand", "isClosed", false); + updateChannel("leftHand"); + } + else + { + setDataField("rightHand", "isOpen", true); + setDataField("rightHand", "isClosed", false); + updateChannel("rightHand"); + } +} + + +void HandUnitObserver::reportHandPreshaped(bool isLeftHand, const Ice::Current&) +{ + if (isLeftHand) + { + setDataField("leftHand", "isOpen", false); + setDataField("leftHand", "isClosed", false); + updateChannel("leftHand"); + } + else + { + setDataField("rightHand", "isOpen", false); + setDataField("rightHand", "isClosed", false); + updateChannel("rightHand"); + } +} + + + +void HandUnitObserver::reportNewHandShapeName(bool isLeftHand, const std::string& handShapeName, const Ice::Current&) +{ + if (isLeftHand) + { + setDataField("leftHand", "shapeName", handShapeName); + updateChannel("leftHand"); + } + else + { + setDataField("rightHand", "shapeName", handShapeName); + updateChannel("rightHand"); + } +} diff --git a/source/RobotAPI/units/HandUnitObserver.h b/source/RobotAPI/units/HandUnitObserver.h new file mode 100644 index 0000000000000000000000000000000000000000..74d9a20d52c23a66c2c56c17fd1d45a1e0f96abb --- /dev/null +++ b/source/RobotAPI/units/HandUnitObserver.h @@ -0,0 +1,77 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::units + * @author David Schiebener <schiebener at kit dot edu> + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl.txt + * GNU General Public License + */ + +#ifndef _ARMARX_ROBOTAPI_HAND_UNIT_OBSERVER_H +#define _ARMARX_ROBOTAPI_HAND_UNIT_OBSERVER_H + +#include <RobotAPI/interface/units/HandUnitInterface.h> +#include <Core/observers/Observer.h> + + +namespace armarx +{ + + class HandUnitObserverPropertyDefinitions: + public ComponentPropertyDefinitions + { + public: + HandUnitObserverPropertyDefinitions(std::string prefix): + ComponentPropertyDefinitions(prefix) + { + //defineRequiredProperty<std::string>("HapticTopicName", "Name of the HapticUnit Topic"); + } + }; + + + class HandUnitObserver : + virtual public Observer, + virtual public HandUnitListener + { + public: + HandUnitObserver(); + + //void setTopicName(std::string topicName); + + // framework hooks + virtual std::string getDefaultName() const { return "HandUnitObserver"; } + virtual void onInitObserver(); + virtual void onConnectObserver(); + virtual void onExitObserver(); + + // observer interface + virtual void reportHandClosed(bool isLeftHand, const ::Ice::Current& = ::Ice::Current()); + virtual void reportHandOpened(bool isLeftHand, const ::Ice::Current& = ::Ice::Current()); + virtual void reportHandPreshaped(bool isLeftHand, const ::Ice::Current& = ::Ice::Current()); + virtual void reportNewHandShapeName(bool isLeftHand, const ::std::string& handShapeName, const ::Ice::Current& = ::Ice::Current()); + + /** + * @see PropertyUser::createPropertyDefinitions() + */ + //virtual PropertyDefinitionsPtr createPropertyDefinitions(); + private: + + + }; +} + +#endif