Skip to content
Snippets Groups Projects
Commit ee9945f4 authored by Raphael's avatar Raphael
Browse files

added listener relay classes

they pass all data they receive to configurable callbacks
parent 3b7b43c3
No related branches found
No related tags found
No related merge requests found
......@@ -74,3 +74,5 @@ set(LIB_FILES
)
armarx_add_library("${LIB_NAME}" "${LIB_FILES}" "${LIB_HEADERS}" "${LIBS}")
add_subdirectory(relays)
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}")
/*
* 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>;
}
/*
* 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>;
}
/*
* 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>;
}
/*
* 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>;
}
#include "KinematicUnitListenerRelay.h"
#include "InertialMeasurementUnitListenerRelay.h"
#include "ForceTorqueUnitListenerRelay.h"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment