diff --git a/interface/slice/units/HapticUnit.ice b/interface/slice/units/HapticUnit.ice new file mode 100644 index 0000000000000000000000000000000000000000..51be7139e96ae67cf2b48bd62d14094a4d851967 --- /dev/null +++ b/interface/slice/units/HapticUnit.ice @@ -0,0 +1,52 @@ +/* + * 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 + * @author Peter Kaiser <peter dot kaiser at kit dot edu> + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_ROBOTAPI_UNITS_HAPTIC_SLICE_ +#define _ARMARX_ROBOTAPI_UNITS_HAPTIC_SLICE_ + +#include <units/UnitInterface.ice> +#include <core/UserException.ice> +#include <core/BasicTypes.ice> +#include <observers/VariantBase.ice> +#include <observers/Matrix.ice> +#include <observers/ObserverInterface.ice> +#include <robotstate/RobotState.ice> + +module armarx +{ + interface HapticUnitInterface extends armarx::SensorActorUnitInterface + { + }; + + interface HapticUnitListener + { + void reportSensorValues(string type, MatrixFloatBase values); + }; + + interface HapticUnitObserverInterface extends ObserverInterface, HapticUnitListener + { + }; + +}; + +#endif diff --git a/source/RobotAPI/units/CMakeLists.txt b/source/RobotAPI/units/CMakeLists.txt index 65eae2401682f6ffd203f5214b1289e3bad5ef9b..0f515c7ed32893f4d69c109fb63482cd12702ed4 100644 --- a/source/RobotAPI/units/CMakeLists.txt +++ b/source/RobotAPI/units/CMakeLists.txt @@ -22,6 +22,8 @@ set(LIBS RobotAPIInterfaces RobotAPICore ArmarXInterfaces ArmarXCore ArmarXCoreO set(LIB_HEADERS ForceTorqueObserver.h ForceTorqueUnit.h + HapticObserver.h + HapticUnit.h TCPControlUnit.h TCPControlUnitObserver.h ) @@ -29,6 +31,8 @@ set(LIB_HEADERS set(LIB_FILES ForceTorqueObserver.cpp ForceTorqueUnit.cpp + HapticObserver.cpp + HapticObserver.h TCPControlUnit.cpp TCPControlUnitObserver.cpp ) diff --git a/source/RobotAPI/units/HapticObserver.cpp b/source/RobotAPI/units/HapticObserver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ca002cd83ceec4cf865dfcdf8a1e1c4d89107d77 --- /dev/null +++ b/source/RobotAPI/units/HapticObserver.cpp @@ -0,0 +1,63 @@ +#include "HapticObserver.h" + +#include <Core/observers/checks/ConditionCheckUpdated.h> +#include <Core/observers/checks/ConditionCheckEquals.h> +#include <Core/observers/checks/ConditionCheckInRange.h> +#include <Core/observers/checks/ConditionCheckLarger.h> +#include <Core/observers/checks/ConditionCheckSmaller.h> +#include <Core/robotstate/remote/checks/ConditionCheckMagnitudeChecks.h> + +#include <Core/robotstate/remote/RobotStateObjectFactories.h> + +using namespace armarx; + +HapticObserver::HapticObserver() +{ +} + +void HapticObserver::setTopicName(std::string topicName) +{ + this->topicName = topicName; +} + +void HapticObserver::onInitObserver() +{ + if(topicName.empty()) + usingTopic(getProperty<std::string>("HapticTopicName").getValue()); + else + usingTopic(topicName); + + // register all checks + offerConditionCheck("updated", new ConditionCheckUpdated()); + offerConditionCheck("larger", new ConditionCheckLarger()); + offerConditionCheck("equals", new ConditionCheckEquals()); + offerConditionCheck("smaller", new ConditionCheckSmaller()); +// offerConditionCheck("magnitudeinrange", new ConditionCheckInRange()); + offerConditionCheck("magnitudelarger", new ConditionCheckMagnitudeLarger()); +// offerConditionCheck("magnitudesmaller", new ConditionCheckSmaller()); + + // register all channels +// offerChannel(FORCETORQUEVECTORS,"Force and Torque vectors on specific parts of the robot."); + +// offerChannel(RAWFORCE,"Forces on specific parts of the robot."); +// offerChannel(OFFSETFORCE,"Force Torques of specific parts of the robot with an offset."); +// offerChannel(FILTEREDFORCE,"Gaussian filtered force torques of specific parts of the robot."); + +// offerChannel(RAWTORQUE,"Torques on specific parts of the robot."); + +} + +void HapticObserver::onConnectObserver() +{ +} + +void HapticObserver::reportSensorValues(const std::string &type, const MatrixFloat &values, const Ice::Current &) +{ + // TODO +} + +PropertyDefinitionsPtr HapticObserver::createPropertyDefinitions() +{ + return PropertyDefinitionsPtr(new HapticObserverPropertyDefinitions( + getConfigIdentifier())); +} diff --git a/source/RobotAPI/units/HapticObserver.h b/source/RobotAPI/units/HapticObserver.h new file mode 100644 index 0000000000000000000000000000000000000000..20a43213bcde58ce5e76dd3c8dad9d8afa7c5a90 --- /dev/null +++ b/source/RobotAPI/units/HapticObserver.h @@ -0,0 +1,72 @@ +/** + * 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 ArmarXCore::units + * @author Peter Kaiser <peter dot kaiser at kit dot edu> + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl.txt + * GNU General Public License + */ + +#ifndef _ARMARX_ROBOTAPI_HAPTIC_OBSERVER_H +#define _ARMARX_ROBOTAPI_HAPTIC_OBSERVER_H + +#include <RobotAPI/interface/units/HapticUnit.h> +#include <Core/observers/Observer.h> +#include <Core/observers/variant/MatrixVariant.h> + +namespace armarx +{ + + class HapticObserverPropertyDefinitions: + public ComponentPropertyDefinitions + { + public: + HapticObserverPropertyDefinitions(std::string prefix): + ComponentPropertyDefinitions(prefix) + { + defineRequiredProperty<std::string>("HapticTopicName", "Name of the HapticUnit Topic"); + } + }; + + class HapticObserver : + virtual public Observer, + virtual public HapticUnitObserverInterface + { + public: + HapticObserver(); + + void setTopicName(std::string topicName); + + // framework hooks + virtual std::string getDefaultName() const { return "HapticUnitObserver"; } + void onInitObserver(); + void onConnectObserver(); + + void reportSensorValues(const std::string &type, const ::armarx::MatrixFloat &values, const ::Ice::Current& = ::Ice::Current()); + + /** + * @see PropertyUser::createPropertyDefinitions() + */ + virtual PropertyDefinitionsPtr createPropertyDefinitions(); + private: + armarx::Mutex dataMutex; + std::string topicName; + + }; +} + +#endif diff --git a/source/RobotAPI/units/HapticUnit.cpp b/source/RobotAPI/units/HapticUnit.cpp new file mode 100644 index 0000000000000000000000000000000000000000..08f16320b459e4cefb06802c3b5703f8562d0a47 --- /dev/null +++ b/source/RobotAPI/units/HapticUnit.cpp @@ -0,0 +1,49 @@ +/** + * 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 ArmarXCore::units + * @author Peter Kaiser <peter dot kaiser at kit dot edu> + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl.txt + * GNU General Public License + */ + +#include "HapticUnit.h" + +using namespace armarx; + +void HapticUnit::onInitComponent() +{ + listenerName = "HapticValues"; + offeringTopic(listenerName); + onInitForceTorqueUnit(); +} + +void HapticUnit::onConnectComponent() +{ + listenerPrx = getTopic<HapticUnitListenerPrx>(listenerName); + onStartHapticUnit(); +} + +void HapticUnit::onExitComponent() +{ + onExitHapticUnit(); +} + +PropertyDefinitionsPtr HapticUnit::createPropertyDefinitions() +{ + return PropertyDefinitionsPtr(new HapticUnitPropertyDefinitions(getConfigIdentifier())); +} diff --git a/source/RobotAPI/units/HapticUnit.h b/source/RobotAPI/units/HapticUnit.h new file mode 100644 index 0000000000000000000000000000000000000000..32c72cb14f7eb2a3d8ef90643842c87f04641487 --- /dev/null +++ b/source/RobotAPI/units/HapticUnit.h @@ -0,0 +1,71 @@ +/** + * 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 ArmarXCore::units + * @author Peter Kaiser <peter dot kaiser at kit dot edu> + * @date 2014 + * @copyright http://www.gnu.org/licenses/gpl.txt + * GNU General Public License + */ + +#ifndef _ARMARX_COMPONENT_HAPTIC_UNIT_H +#define _ARMARX_COMPONENT_HAPTIC_UNIT_H + +#include <Core/core/Component.h> +#include <Core/core/application/properties/Properties.h> +#include <Core/core/system/ImportExportComponent.h> +#include "Core/units/SensorActorUnit.h" + +#include <RobotAPI/interface/units/HapticUnit.h> + +#include <string> + +namespace armarx +{ + class HapticUnitPropertyDefinitions : public ComponentPropertyDefinitions + { + public: + HapticUnitPropertyDefinitions(std::string prefix) : + ComponentPropertyDefinitions(prefix) + { + // No required properties + } + }; + + class HapticUnit : + virtual public HapticUnitInterface, + virtual public SensorActorUnit + { + public: + virtual std::string getDefaultName() const { return "HapticUnit"; } + + virtual void onInitComponent(); + virtual void onConnectComponent(); + virtual void onExitComponent(); + + virtual void onInitHapticUnit() = 0; + virtual void onStartHapticUnit() = 0; + virtual void onExitHapticUnit() = 0; + + virtual PropertyDefinitionsPtr createPropertyDefinitions(); + + protected: + HapticUnitListenerPrx listenerPrx; + std::string listenerName; + }; +} + +#endif