diff --git a/source/RobotAPI/applications/CMakeLists.txt b/source/RobotAPI/applications/CMakeLists.txt index 343addf16d384b97802185c482262eaea61242d9..63328dbb33accad3fe1cae87414fce09238e92fe 100644 --- a/source/RobotAPI/applications/CMakeLists.txt +++ b/source/RobotAPI/applications/CMakeLists.txt @@ -20,3 +20,5 @@ add_subdirectory(PlatformUnitSimulation) add_subdirectory(PlatformUnitObserver) add_subdirectory(RobotStateComponent) add_subdirectory(RobotStateObserver) + +add_subdirectory(HandUnitObserver) \ No newline at end of file diff --git a/source/RobotAPI/applications/HandUnitObserver/CMakeLists.txt b/source/RobotAPI/applications/HandUnitObserver/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ddfca935c3cbc959370f68d3bc05512287412cba --- /dev/null +++ b/source/RobotAPI/applications/HandUnitObserver/CMakeLists.txt @@ -0,0 +1,16 @@ +armarx_component_set_name("HandUnitObserverApp") + +#find_package(MyLib QUIET) +#armarx_build_if(MyLib_FOUND "MyLib not available") +# +# all include_directories must be guarded by if(Xyz_FOUND) +# for multiple libraries write: if(X_FOUND AND Y_FOUND).... +#if(MyLib_FOUND) +# include_directories(${MyLib_INCLUDE_DIRS}) +#endif() + +set(COMPONENT_LIBS RobotAPIUnits ArmarXInterfaces ArmarXCore) + +set(EXE_SOURCE main.cpp) + +armarx_add_component_executable("${EXE_SOURCE}") diff --git a/source/RobotAPI/applications/HandUnitObserver/HandUnitObserverApp.h b/source/RobotAPI/applications/HandUnitObserver/HandUnitObserverApp.h new file mode 100644 index 0000000000000000000000000000000000000000..3a8cbcf77d5b9bf22738ce91f8e8e28ef81c6d0a --- /dev/null +++ b/source/RobotAPI/applications/HandUnitObserver/HandUnitObserverApp.h @@ -0,0 +1,54 @@ +/* + * 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::application::HandUnitObserver + * @author Mirko Waechter ( mirko dot waechter at kit dot edu ) + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl.txt + * GNU General Public License + */ + +#ifndef _ARMARX_APPLICATION_RobotAPI_HandUnitObserver_H +#define _ARMARX_APPLICATION_RobotAPI_HandUnitObserver_H + + + #include <RobotAPI/units/HandUnitObserver.h> + +#include <Core/core/application/Application.h> + +namespace armarx +{ + /** + * @class HandUnitObserverApp + * @brief A brief description + * + * Detailed Description + */ + class HandUnitObserverApp : + virtual public armarx::Application + { + /** + * @see armarx::Application::setup() + */ + void setup(const ManagedIceObjectRegistryInterfacePtr& registry, + Ice::PropertiesPtr properties) + { + registry->addObject( Component::create<HandUnitObserver>(properties) ); + } + }; +} + +#endif diff --git a/source/RobotAPI/applications/HandUnitObserver/main.cpp b/source/RobotAPI/applications/HandUnitObserver/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..340d409641c29ba3a02ea68e5a7d15ca412ff234 --- /dev/null +++ b/source/RobotAPI/applications/HandUnitObserver/main.cpp @@ -0,0 +1,33 @@ +/* + * 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::application::HandUnitObserver + * @author Mirko Waechter ( mirko dot waechter at kit dot edu ) + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl.txt + * GNU General Public License + */ + +#include "HandUnitObserverApp.h" +#include <Core/core/logging/Logging.h> + +int main(int argc, char* argv[]) +{ + armarx::ApplicationPtr app = armarx::Application::createInstance < armarx::HandUnitObserverApp > (); + app->setName("HandUnitObserver"); + + return app->main(argc, argv); +} diff --git a/source/RobotAPI/interface/units/HandUnitInterface.ice b/source/RobotAPI/interface/units/HandUnitInterface.ice index 3b64ffd2f7caecf350401d8c5cafa467d20c1740..582ebe79f85bab74fa0cdfad7dc664b270edccb0 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 { @@ -56,14 +58,21 @@ module armarx void setObjectReleased(string objectName); }; - interface HandUnitListener + interface HandUnitListener extends armarx::ObserverInterface { +<<<<<<< HEAD void reportHandClosed(); void reportHandOpened(); void reportHandPreshaped(); // informs all listeners that we grasped an object void reportObjectGrasped(string robotName, string robotNodeName, string objectName); +======= + void reportHandClosed(bool isLeftHand); + void reportHandOpened(bool isLeftHand); + void reportHandPreshaped(bool isLeftHand); + void reportNewHandShapeName(bool isLeftHand, string handShapeName); +>>>>>>> 2f3326fdfecad75fe7a1047e694a6857ba78b6aa }; }; diff --git a/source/RobotAPI/robotstate/remote/CMakeLists.txt b/source/RobotAPI/robotstate/remote/CMakeLists.txt index e2467fb00728633d76cc178e089e80d42b0f90e0..8540a5d250ede4b1a15bb53c14900b1faeb8795e 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) @@ -24,6 +24,7 @@ set(LIB_FILES ArmarPose.cpp RemoteRobot.cpp RemoteRobotNode.cpp checks/ConditionCheckMagnitudeChecks.cpp + RobotStateObjectFactories.cpp ) set(LIB_HEADERS ArmarPose.h LinkedPose.h 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/robotstate/remote/RobotStateObjectFactories.cpp b/source/RobotAPI/robotstate/remote/RobotStateObjectFactories.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af1999ea36988e3bb0c121ef3b39e632efce6aec --- /dev/null +++ b/source/RobotAPI/robotstate/remote/RobotStateObjectFactories.cpp @@ -0,0 +1,27 @@ +/* +* 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 ArmarX:: +* @author Mirko Waechter ( mirko.waechter at kit dot edu) +* @date 2014 +* @copyright http://www.gnu.org/licenses/gpl.txt +* GNU General Public License +*/ + +#include "RobotStateObjectFactories.h" +using namespace armarx; +using namespace armarx::ObjectFactories; +const FactoryCollectionBaseCleanUp RobotStateObjectFactories::RobotStateObjectFactoriesVar = FactoryCollectionBase::addToPreregistration(new RobotStateObjectFactories()); diff --git a/source/RobotAPI/robotstate/remote/RobotStateObjectFactories.h b/source/RobotAPI/robotstate/remote/RobotStateObjectFactories.h index 75fd46891106e162941b6b8c0ddf155e94711d10..d9bf208af9a26a3fe50813f7d4ad7c9135869e66 100644 --- a/source/RobotAPI/robotstate/remote/RobotStateObjectFactories.h +++ b/source/RobotAPI/robotstate/remote/RobotStateObjectFactories.h @@ -169,8 +169,8 @@ namespace armarx return map; } + static const FactoryCollectionBaseCleanUp RobotStateObjectFactoriesVar; }; - const FactoryCollectionBaseCleanUp RobotStateObjectFactoriesVar = FactoryCollectionBase::addToPreregistration(new RobotStateObjectFactories()); } } 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..98134d4fd2dd18b180eafe2405e353f8658aa06b --- /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