diff --git a/source/RobotAPI/components/units/CMakeLists.txt b/source/RobotAPI/components/units/CMakeLists.txt index 94ed1485e1eabb750ad5ae80748008faea129bc6..90567cf96caddb0d174100b504237265888f06a2 100644 --- a/source/RobotAPI/components/units/CMakeLists.txt +++ b/source/RobotAPI/components/units/CMakeLists.txt @@ -74,3 +74,5 @@ set(LIB_FILES ) armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}") + +add_subdirectory(relays) diff --git a/source/RobotAPI/components/units/relays/CMakeLists.txt b/source/RobotAPI/components/units/relays/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..26d539f34c8e5624a614fa891b8f7a19a04f01fd --- /dev/null +++ b/source/RobotAPI/components/units/relays/CMakeLists.txt @@ -0,0 +1,16 @@ +set(LIB_NAME RobotAPIUnitListenerRelays) +armarx_set_target("RobotAPI Unit Listener Relays Library: ${LIB_NAME}") + +set(LIBS ArmarXCore RobotAPIInterfaces) + +set(LIB_HEADERS + KinematicUnitListenerRelay.h + InertialMeasurementUnitListenerRelay.h + ForceTorqueUnitListenerRelay.h + RobotStateListenerRelay.h +) + +set(LIB_FILES syntaxcheck.cpp) + +armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}") + diff --git a/source/RobotAPI/components/units/relays/ForceTorqueUnitListenerRelay.h b/source/RobotAPI/components/units/relays/ForceTorqueUnitListenerRelay.h new file mode 100644 index 0000000000000000000000000000000000000000..581a1d175f57226d5d93dfc76f18c4bed13cc9e1 --- /dev/null +++ b/source/RobotAPI/components/units/relays/ForceTorqueUnitListenerRelay.h @@ -0,0 +1,56 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 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 VisionX::ArmarXObjects::ForceTorqueUnitListenerRelay + * @author Raphael Grimm ( ufdrv at student dot kit dot edu ) + * @date 2016 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#include <ArmarXCore/core/ManagedIceObject.h> +#include <ArmarXCore/core/util/noop.h> +#include <RobotAPI/interface/units/ForceTorqueUnit.h> + +namespace armarx +{ + class ForceTorqueUnitListenerRelay : + virtual public ManagedIceObject, + virtual public ForceTorqueUnitListener + { + public: + using CallbackFunctionSensorValues = std::function<void(const std::string&, const FramedDirectionBasePtr&, const FramedDirectionBasePtr&)>; + + // ForceTorqueUnitListener interface + virtual void reportSensorValues(const std::string& sensorNodeName, const FramedDirectionBasePtr& forces, const FramedDirectionBasePtr& torques, const Ice::Current& = GlobalIceCurrent) + { + callbackReportSensorValues(sensorNodeName, forces, torques); + } + protected: + // ManagedIceObject interface + virtual void onInitComponent() + { + usingTopic(topicName); + } + virtual void onConnectComponent() {} + virtual std::string getDefaultName() const + { + return "ForceTorqueUnitListenerRelay"; + } + public: + std::string topicName; + CallbackFunctionSensorValues callbackReportSensorValues {noop<const std::string&, const FramedDirectionBasePtr&, const FramedDirectionBasePtr&>}; + }; + using ForceTorqueUnitListenerRelayPtr = IceInternal::Handle<ForceTorqueUnitListenerRelay>; +} diff --git a/source/RobotAPI/components/units/relays/InertialMeasurementUnitListenerRelay.h b/source/RobotAPI/components/units/relays/InertialMeasurementUnitListenerRelay.h new file mode 100644 index 0000000000000000000000000000000000000000..69e2b0c1bab1d394517684a60ab328d3a95ec55d --- /dev/null +++ b/source/RobotAPI/components/units/relays/InertialMeasurementUnitListenerRelay.h @@ -0,0 +1,56 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 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 VisionX::ArmarXObjects::InertialMeasurementUnitListenerRelay + * @author Raphael Grimm ( ufdrv at student dot kit dot edu ) + * @date 2016 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#include <ArmarXCore/core/ManagedIceObject.h> +#include <ArmarXCore/core/util/noop.h> +#include <RobotAPI/interface/units/InertialMeasurementUnit.h> + +namespace armarx +{ + class InertialMeasurementUnitListenerRelay : + virtual public ManagedIceObject, + virtual public InertialMeasurementUnitListener + { + public: + using CallbackFunctionSensorValues = std::function<void(const std::string&, const std::string&, const IMUData&, const TimestampBasePtr&)>; + + // InertialMeasurementUnitListener interface + virtual void reportSensorValues(const std::string& device, const std::string& name, const IMUData& values, const TimestampBasePtr& timestamp, const Ice::Current& = GlobalIceCurrent) + { + callbackReportSensorValues(device, name, values, timestamp); + } + protected: + // ManagedIceObject interface + virtual void onInitComponent() + { + usingTopic(topicName); + } + virtual void onConnectComponent() {} + virtual std::string getDefaultName() const + { + return "InertialMeasurementUnitListenerRelay"; + } + public: + std::string topicName; + CallbackFunctionSensorValues callbackReportSensorValues {noop<const std::string&, const std::string&, const IMUData&, const TimestampBasePtr&>}; + }; + using InertialMeasurementUnitListenerRelayPtr = IceInternal::Handle<InertialMeasurementUnitListenerRelay>; +} diff --git a/source/RobotAPI/components/units/relays/KinematicUnitListenerRelay.h b/source/RobotAPI/components/units/relays/KinematicUnitListenerRelay.h new file mode 100644 index 0000000000000000000000000000000000000000..cbf2d2e2bab5bdc57acadcbb9b78f4fbcca806cb --- /dev/null +++ b/source/RobotAPI/components/units/relays/KinematicUnitListenerRelay.h @@ -0,0 +1,94 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 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 VisionX::ArmarXObjects::KinematicUnitListenerRelay + * @author Raphael Grimm ( ufdrv at student dot kit dot edu ) + * @date 2016 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#include <ArmarXCore/core/ManagedIceObject.h> +#include <ArmarXCore/core/util/noop.h> +#include <RobotAPI/interface/units/KinematicUnitInterface.h> + +namespace armarx +{ + class KinematicUnitListenerRelay : + virtual public ManagedIceObject, + virtual public KinematicUnitListener + { + public: + using CallbackFunctionModes = std::function<void(const NameControlModeMap&, Ice::Long, bool)>; + using CallbackFunctionState = std::function<void(const NameStatusMap&, Ice::Long, bool)>; + using CallbackFunctionValue = std::function<void(const NameValueMap&, Ice::Long, bool)>; + + // KinematicUnitListener interface + virtual void reportControlModeChanged(const NameControlModeMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportControlModeChanged(map, time, changes); + } + virtual void reportJointAngles(const NameValueMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportJointAngles(map, time, changes); + } + virtual void reportJointVelocities(const NameValueMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportJointVelocities(map, time, changes); + } + virtual void reportJointTorques(const NameValueMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportJointTorques(map, time, changes); + } + virtual void reportJointAccelerations(const NameValueMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportJointAccelerations(map, time, changes); + } + virtual void reportJointCurrents(const NameValueMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportJointCurrents(map, time, changes); + } + virtual void reportJointMotorTemperatures(const NameValueMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportJointMotorTemperatures(map, time, changes); + } + virtual void reportJointStatuses(const NameStatusMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportJointStatuses(map, time, changes); + } + + protected: + // ManagedIceObject interface + virtual void onInitComponent() + { + usingTopic(topicName); + } + virtual void onConnectComponent() {} + virtual std::string getDefaultName() const + { + return "KinematicUnitListenerRelay"; + } + public: + std::string topicName; + CallbackFunctionModes callbackReportControlModeChanged {noop<const NameControlModeMap&, Ice::Long, bool>}; + CallbackFunctionValue callbackReportJointAngles {noop<const NameValueMap&, Ice::Long, bool>}; + CallbackFunctionValue callbackReportJointVelocities {noop<const NameValueMap&, Ice::Long, bool>}; + CallbackFunctionValue callbackReportJointTorques {noop<const NameValueMap&, Ice::Long, bool>}; + CallbackFunctionValue callbackReportJointAccelerations {noop<const NameValueMap&, Ice::Long, bool>}; + CallbackFunctionValue callbackReportJointCurrents {noop<const NameValueMap&, Ice::Long, bool>}; + CallbackFunctionValue callbackReportJointMotorTemperatures {noop<const NameValueMap&, Ice::Long, bool>}; + CallbackFunctionState callbackReportJointStatuses {noop<const NameStatusMap&, Ice::Long, bool>}; + }; + using KinematicUnitListenerRelayPtr = IceInternal::Handle<KinematicUnitListenerRelay>; +} diff --git a/source/RobotAPI/components/units/relays/RobotStateListenerRelay.h b/source/RobotAPI/components/units/relays/RobotStateListenerRelay.h new file mode 100644 index 0000000000000000000000000000000000000000..839160995c58304031c199884a0e7fbac3517661 --- /dev/null +++ b/source/RobotAPI/components/units/relays/RobotStateListenerRelay.h @@ -0,0 +1,61 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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 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 VisionX::ArmarXObjects::KinematicUnitListenerRelay + * @author Raphael Grimm ( ufdrv at student dot kit dot edu ) + * @date 2016 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#include <ArmarXCore/core/ManagedIceObject.h> +#include <ArmarXCore/core/util/noop.h> +#include <RobotAPI/interface/core/RobotState.h> + +namespace armarx +{ + class RobotStateListenerRelay : + virtual public ManagedIceObject, + virtual public RobotStateListenerInterface + { + public: + using CallbackFunctionValue = std::function<void(const NameValueMap& , Ice::Long, bool)>; + using CallbackFunctionPose = std::function<void(const FramedPoseBasePtr &, Ice::Long, bool)>; + + virtual void reportJointValues(const NameValueMap& map, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportJointValues(map, time, changes); + } + void reportGlobalRobotRootPose(const FramedPoseBasePtr & pose, Ice::Long time, bool changes, const Ice::Current& = GlobalIceCurrent) + { + callbackReportGlobalRobotRootPose(pose, time, changes); + } + protected: + // ManagedIceObject interface + virtual void onInitComponent() + { + usingTopic(topicName); + } + virtual void onConnectComponent() {} + virtual std::string getDefaultName() const + { + return "RobotStateListener"; + } + public: + std::string topicName; + CallbackFunctionValue callbackReportJointValues {noop<const NameValueMap& , Ice::Long, bool>}; + CallbackFunctionPose callbackReportGlobalRobotRootPose {noop<const FramedPoseBasePtr &, Ice::Long, bool>}; + }; + using RobotStateListenerRelayPtr = IceInternal::Handle<RobotStateListenerRelay>; +} diff --git a/source/RobotAPI/components/units/relays/syntaxcheck.cpp b/source/RobotAPI/components/units/relays/syntaxcheck.cpp new file mode 100644 index 0000000000000000000000000000000000000000..82b6a31b758ca9668e4219e346f9ae3be5e4a477 --- /dev/null +++ b/source/RobotAPI/components/units/relays/syntaxcheck.cpp @@ -0,0 +1,3 @@ +#include "KinematicUnitListenerRelay.h" +#include "InertialMeasurementUnitListenerRelay.h" +#include "ForceTorqueUnitListenerRelay.h"