Skip to content
Snippets Groups Projects
Commit 4a7a02db authored by Peter Kaiser's avatar Peter Kaiser
Browse files

Added HapticUnit and HapticObserver

parent f2a91de4
No related branches found
No related tags found
No related merge requests found
/*
* 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
......@@ -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
)
......
#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()));
}
/**
* 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
/**
* 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()));
}
/**
* 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
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