Skip to content
Snippets Groups Projects
Commit b37e0a78 authored by Simon Ottenhaus's avatar Simon Ottenhaus
Browse files

added test statechart for Weiss Tactile Sensors

parent 17087d55
No related branches found
No related tags found
No related merge requests found
Showing
with 958 additions and 18 deletions
...@@ -26,6 +26,23 @@ ...@@ -26,6 +26,23 @@
propertyName="ForceTorqueUnitObserverName" propertyName="ForceTorqueUnitObserverName"
propertyIsOptional="true" propertyIsOptional="true"
propertyDefaultValue="ForceTorqueUnitObserver" /> propertyDefaultValue="ForceTorqueUnitObserver" />
<Proxy include="RobotAPI/interface/units/HapticUnit.h"
humanName="Haptic Unit Observer"
typeName="HapticUnitObserverInterfacePrx"
memberName="hapticObserver"
getterName="getHapticObserver"
propertyName="HapticUnitObserverName"
propertyIsOptional="true"
propertyDefaultValue="HapticUnitObserver" />
<Proxy include="RobotAPI/interface/units/WeissHapticUnit.h"
humanName="Weiss Haptic Unit"
typeName="WeissHapticUnitInterfacePrx"
memberName="weissHapticUnit"
getterName="getWeissHapticUnit"
propertyName="WeissHapticUnitName"
propertyIsOptional="true"
propertyDefaultValue="WeissHapticUnit" />
<Proxy include="RobotAPI/interface/core/RobotState.h" <Proxy include="RobotAPI/interface/core/RobotState.h"
humanName="Robot State Component" humanName="Robot State Component"
typeName="RobotStateComponentInterfacePrx" typeName="RobotStateComponentInterfacePrx"
......
set(SCENARIO_CONFIG_COMPONENTS
config/RobotControl.cfg
config/WeissHapticUnitApp.cfg
config/XMLRemoteStateOfferer.WeissHapticGroup.cfg
config/SystemObserver.cfg
config/ConditionHandler.cfg
set(SCENARIO_COMPONENTS
WeissHapticUnitApp #WeissHapticUnitApp
#WeissHapticSensorApp #WeissHapticSensorApp
#HapticObserverApp #HapticObserverApp
) )
# optional 3rd parameter: "path/to/global/config.cfg" # optional 3rd parameter: "path/to/global/config.cfg"
armarx_scenario("WeissHapticSensorsUnitTest" "${SCENARIO_COMPONENTS}") armarx_scenario_from_configs("WeissHapticSensorsUnitTest" "${SCENARIO_CONFIG_COMPONENTS}")
#set(SCENARIO_CONFIGS
# config/ComponentName.optionalString.cfg
# )
# optional 3rd parameter: "path/to/global/config.cfg"
#armarx_scenario_from_configs("WeissHapticSensorsUnitTest" "${SCENARIO_CONFIGS}")
# ==================================================================
# ArmarX properties
# ==================================================================
# ArmarX.CachePath: Path for cache files
# Attributes:
# - Default: ${HOME}/.armarx/mongo/.cache
# - Case sensitivity: no
# - Required: no
# ArmarX.CachePath = ${HOME}/.armarx/mongo/.cache
# ArmarX.DataPath: Semicolon-separated search list for data files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DataPath = ""
# ArmarX.Verbosity: Global logging level for whole application
# Attributes:
# - Default: Verbose
# - Case sensitivity: no
# - Required: no
# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning}
# ArmarX.Verbosity = Verbose
# ArmarX.DisableLogging: Turn logging off in whole application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# - Possible values: {0, 1, false, no, true, yes}
# ArmarX.DisableLogging = 0
# ArmarX.ApplicationName: Application name
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ApplicationName = ""
# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited.
# Attributes:
# - Default: ./config/dependencies.cfg
# - Case sensitivity: no
# - Required: no
# ArmarX.DependenciesConfig = ./config/dependencies.cfg
# ArmarX.Config: Comma-separated list of configuration files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.Config = ""
# ==================================================================
# ArmarX.ConditionHandler properties
# ==================================================================
# ArmarX.ConditionHandler.HistoryLength: Length of condition history kept by the conditionhandler
# Attributes:
# - Default: 1000
# - Case sensitivity: no
# - Required: no
# ArmarX.ConditionHandler.HistoryLength = 1000
# ArmarX.ConditionHandler.Observers: Comma seperated observer list
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ConditionHandler.Observers = ""
# ArmarX.ConditionHandler.MinimumLoggingLevel: Local logging level only for this component
# Attributes:
# - Default: Undefined
# - Case sensitivity: no
# - Required: no
# - Possible values: {Error, Fatal, Info, Undefined, Verbose, Warning}
# ArmarX.ConditionHandler.MinimumLoggingLevel = Undefined
# ArmarX.ConditionHandler.ObjectName: Name of IceGrid well-known object
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ConditionHandler.ObjectName = ""
# ==================================================================
# ArmarX properties
# ==================================================================
# ArmarX.CachePath: Path for cache files
# Attributes:
# - Default: ${HOME}/.armarx/mongo/.cache
# - Case sensitivity: no
# - Required: no
# ArmarX.CachePath = ${HOME}/.armarx/mongo/.cache
# ArmarX.DataPath: Semicolon-separated search list for data files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DataPath = ""
# ArmarX.Verbosity: Global logging level for whole application
# Attributes:
# - Default: Verbose
# - Case sensitivity: no
# - Required: no
# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning}
# ArmarX.Verbosity = Verbose
# ArmarX.DisableLogging: Turn logging off in whole application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# - Possible values: {0, 1, false, no, true, yes}
# ArmarX.DisableLogging = 0
# ArmarX.ApplicationName: Application name
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ApplicationName = ""
# ArmarX.DatapathConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited.
# Attributes:
# - Default: ./config/datapath.cfg
# - Case sensitivity: no
# - Required: no
# ArmarX.DatapathConfig = ./config/datapath.cfg
# ArmarX.Config: Comma-separated list of configuration files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.Config = ""
# ==================================================================
# ArmarX.RobotControlStateOfferer properties
# ==================================================================
# ArmarX.RobotControlStateOfferer.stateName: name of the state to load
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
ArmarX.RobotControlStateOfferer.stateName = "WeissHapticSensorTest"
# ArmarX.RobotControlStateOfferer.proxyName: name of the proxy to load
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
ArmarX.RobotControlStateOfferer.proxyName = "WeissHapticGroupRemoteStateOfferer"
# ArmarX.RobotControlStateOfferer.logstates:
# Attributes:
# - Default: Comma seperated list with state names to log. If not set, all transitions will be logged
# - Case sensitivity: no
# - Required: no
# ArmarX.RobotControlStateOfferer.logstates = Comma seperated list with state names to log. If not set, all transitions will be logged
# ArmarX.RobotControlStateOfferer.enableStatechartLogger: disable/enable statechart logger
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# - Possible values: {0, 1, false, no, true, yes}
# ArmarX.RobotControlStateOfferer.enableStatechartLogger = 0
# ArmarX.RobotControlStateOfferer.MinimumLoggingLevel: Local logging level only for this component
# Attributes:
# - Default: Undefined
# - Case sensitivity: no
# - Required: no
# - Possible values: {Error, Fatal, Info, Undefined, Verbose, Warning}
# ArmarX.RobotControlStateOfferer.MinimumLoggingLevel = Undefined
# ArmarX.RobotControlStateOfferer.ObjectName: Name of IceGrid well-known object
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.RobotControlStateOfferer.ObjectName = ""
# ==================================================================
# ArmarX properties
# ==================================================================
# ArmarX.CachePath: Path for cache files
# Attributes:
# - Default: ${HOME}/.armarx/mongo/.cache
# - Case sensitivity: no
# - Required: no
# ArmarX.CachePath = ${HOME}/.armarx/mongo/.cache
# ArmarX.DataPath: Semicolon-separated search list for data files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DataPath = ""
# ArmarX.Verbosity: Global logging level for whole application
# Attributes:
# - Default: Verbose
# - Case sensitivity: no
# - Required: no
# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning}
# ArmarX.Verbosity = Verbose
# ArmarX.DisableLogging: Turn logging off in whole application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# - Possible values: {0, 1, false, no, true, yes}
# ArmarX.DisableLogging = 0
# ArmarX.ApplicationName: Application name
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ApplicationName = ""
# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited.
# Attributes:
# - Default: ./config/dependencies.cfg
# - Case sensitivity: no
# - Required: no
# ArmarX.DependenciesConfig = ./config/dependencies.cfg
# ArmarX.Config: Comma-separated list of configuration files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.Config = ""
# ==================================================================
# ArmarX.SystemObserver properties
# ==================================================================
# ArmarX.SystemObserver.MinimumLoggingLevel: Local logging level only for this component
# Attributes:
# - Default: Undefined
# - Case sensitivity: no
# - Required: no
# - Possible values: {Error, Fatal, Info, Undefined, Verbose, Warning}
# ArmarX.SystemObserver.MinimumLoggingLevel = Undefined
# ArmarX.SystemObserver.ObjectName: Name of IceGrid well-known object
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.SystemObserver.ObjectName = ""
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
# - Default: "" # - Default: ""
# - Case sensitivity: no # - Case sensitivity: no
# - Required: no # - Required: no
# ArmarX.HapticUnit.ObjectName = "" ArmarX.HapticUnit.ObjectName = "WeissHapticUnit"
# ================================================================== # ==================================================================
......
# ==================================================================
# ArmarX properties
# ==================================================================
# ArmarX.CachePath: Path for cache files
# Attributes:
# - Default: ${HOME}/.armarx/mongo/.cache
# - Case sensitivity: no
# - Required: no
# ArmarX.CachePath = ${HOME}/.armarx/mongo/.cache
# ArmarX.DataPath: Semicolon-separated search list for data files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DataPath = ""
# ArmarX.Verbosity: Global logging level for whole application
# Attributes:
# - Default: Verbose
# - Case sensitivity: no
# - Required: no
# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning}
# ArmarX.Verbosity = Verbose
# ArmarX.DisableLogging: Turn logging off in whole application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# - Possible values: {0, 1, false, no, true, yes}
# ArmarX.DisableLogging = 0
# ArmarX.ApplicationName: Application name
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
ArmarX.ApplicationName = "XMLStateComponentWeissHapticGroup"
# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited.
# Attributes:
# - Default: ./config/dependencies.cfg
# - Case sensitivity: no
# - Required: no
# ArmarX.DependenciesConfig = ./config/dependencies.cfg
# ArmarX.Config: Comma-separated list of configuration files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.Config = ""
# ==================================================================
# ArmarX.XMLStateComponent properties
# ==================================================================
# ArmarX.XMLStateComponent.XMLStatechartGroupDefinitionFile: Path to statechart group definition file (*.scgxml) - relative to projects source dir
# Attributes:
# - Case sensitivity: no
# - Required: yes
ArmarX.XMLStateComponent.XMLStatechartGroupDefinitionFile = RobotAPI/statecharts/WeissHapticGroup/WeissHapticGroup.scgxml
# ArmarX.XMLStateComponent.MinimumLoggingLevel: Local logging level only for this component
# Attributes:
# - Default: Undefined
# - Case sensitivity: no
# - Required: no
# - Possible values: {Error, Fatal, Info, Undefined, Verbose, Warning}
# ArmarX.XMLStateComponent.MinimumLoggingLevel = Undefined
# ArmarX.XMLStateComponent.ObjectName: Name of IceGrid well-known object
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
ArmarX.XMLStateComponent.ObjectName = "XMLStateComponentWeissHapticGroup"
export CORE_PATH=../../../Core
export GUI_PATH=../../../Gui
export SCRIPT_PATH=$CORE_PATH/build/bin
export GUI_BIN_PATH=$GUI_PATH/build/bin
# Gui
$SCRIPT_PATH/startApplication.sh $GUI_BIN_PATH/ArmarXGuiRun &
...@@ -67,6 +67,7 @@ void HapticObserver::reportSensorValues(const std::string& device, const std::st ...@@ -67,6 +67,7 @@ void HapticObserver::reportSensorValues(const std::string& device, const std::st
offerDataFieldWithDefault(channelName, "mean", Variant(mean), "Mean value"); offerDataFieldWithDefault(channelName, "mean", Variant(mean), "Mean value");
offerDataFieldWithDefault(channelName, "timestamp", timestampPtr, "Timestamp"); offerDataFieldWithDefault(channelName, "timestamp", timestampPtr, "Timestamp");
offerDataFieldWithDefault(channelName, "rate", Variant(0.0f), "Sample rate"); offerDataFieldWithDefault(channelName, "rate", Variant(0.0f), "Sample rate");
ARMARX_INFO << "Offering new channel: " << channelName;
} }
else else
{ {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <Core/util/variants/eigen3/Eigen3VariantObjectFactories.h> #include <Core/util/variants/eigen3/Eigen3VariantObjectFactories.h>
#include <Core/core/services/tasks/PeriodicTask.h> #include <Core/core/services/tasks/PeriodicTask.h>
namespace armarx namespace armarx
{ {
......
add_subdirectory(operations) add_subdirectory(operations)
add_subdirectory(WeissHapticGroup)
\ No newline at end of file
armarx_component_set_name("WeissHapticGroup")
#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()
find_package(Eigen3 QUIET)
find_package(Simox QUIET)
armarx_build_if(Eigen3_FOUND "Eigen3 not available")
armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
if (Eigen3_FOUND AND Simox_FOUND)
include_directories(
${Eigen3_INCLUDE_DIR}
${Simox_INCLUDE_DIRS}
)
endif()
set(COMPONENT_LIBS
RobotAPIInterfaces RobotAPICore RobotAPIUnits
ArmarXInterfaces ArmarXCore ArmarXCoreStatechart ArmarXCoreObservers)
# Sources
set(SOURCES
WeissHapticGroupRemoteStateOfferer.cpp
./WeissHapticSensorTest.cpp
#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.cpp
)
set(HEADERS
WeissHapticGroupRemoteStateOfferer.h
WeissHapticGroupStatechartContext.generated.h
./WeissHapticSensorTest.h
#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.h
./WeissHapticSensorTest.generated.h
#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.generated.h
)
armarx_add_component("${SOURCES}" "${HEADERS}")
<?xml version="1.0" encoding="utf-8"?>
<StatechartGroup name="WeissHapticGroup" package="RobotAPI" generateContext="true">
<Proxies>
<Proxy value="RobotAPICore.hapticObserver"/>
<Proxy value="RobotAPICore.weissHapticUnit"/>
</Proxies>
<State filename="WeissHapticSensorTest.xml" visibility="public"/>
</StatechartGroup>
/*
* 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 RobotAPI::WeissHapticGroup::WeissHapticGroupRemoteStateOfferer
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2015
* @copyright http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#include "WeissHapticGroupRemoteStateOfferer.h"
using namespace armarx;
using namespace WeissHapticGroup;
// DO NOT EDIT NEXT LINE
WeissHapticGroupRemoteStateOfferer::SubClassRegistry WeissHapticGroupRemoteStateOfferer::Registry(WeissHapticGroupRemoteStateOfferer::GetName(), &WeissHapticGroupRemoteStateOfferer::CreateInstance);
WeissHapticGroupRemoteStateOfferer::WeissHapticGroupRemoteStateOfferer(StatechartGroupXmlReaderPtr reader) :
XMLRemoteStateOfferer < WeissHapticGroupStatechartContext > (reader)
{
}
void WeissHapticGroupRemoteStateOfferer::onInitXMLRemoteStateOfferer()
{
}
void WeissHapticGroupRemoteStateOfferer::onConnectXMLRemoteStateOfferer()
{
}
void WeissHapticGroupRemoteStateOfferer::onExitXMLRemoteStateOfferer()
{
}
// DO NOT EDIT NEXT FUNCTION
std::string WeissHapticGroupRemoteStateOfferer::GetName()
{
return "WeissHapticGroupRemoteStateOfferer";
}
// DO NOT EDIT NEXT FUNCTION
XMLStateOffererFactoryBasePtr WeissHapticGroupRemoteStateOfferer::CreateInstance(StatechartGroupXmlReaderPtr reader)
{
return XMLStateOffererFactoryBasePtr(new WeissHapticGroupRemoteStateOfferer(reader));
}
/*
* 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 RobotAPI::WeissHapticGroup
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2015
* @copyright http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#ifndef _ARMARX_XMLUSERCODE_RobotAPI_WeissHapticGroup_REMOTESTATEOFFERER_H
#define _ARMARX_XMLUSERCODE_RobotAPI_WeissHapticGroup_REMOTESTATEOFFERER_H
#include <Core/statechart/xmlstates/XMLRemoteStateOfferer.h>
#include "WeissHapticGroupStatechartContext.generated.h"
namespace armarx
{
namespace WeissHapticGroup
{
class WeissHapticGroupRemoteStateOfferer :
virtual public XMLRemoteStateOfferer < WeissHapticGroupStatechartContext > // Change this statechart context if you need another context (dont forget to change in the constructor as well)
{
public:
WeissHapticGroupRemoteStateOfferer(StatechartGroupXmlReaderPtr reader);
// inherited from RemoteStateOfferer
void onInitXMLRemoteStateOfferer();
void onConnectXMLRemoteStateOfferer();
void onExitXMLRemoteStateOfferer();
// static functions for AbstractFactory Method
static std::string GetName();
static XMLStateOffererFactoryBasePtr CreateInstance(StatechartGroupXmlReaderPtr reader);
static SubClassRegistry Registry;
};
}
}
#endif
#ifndef ARMARX_COMPONENT_ARMARX_WEISSHAPTICGROUP_WEISSHAPTICGROUPSTATECHARTCONTEXT_H
#define ARMARX_COMPONENT_ARMARX_WEISSHAPTICGROUP_WEISSHAPTICGROUPSTATECHARTCONTEXT_H
#include <Core/core/Component.h>
#include <Core/core/system/ImportExportComponent.h>
#include <Core/statechart/StatechartContext.h>
#include <RobotAPI/interface/units/HapticUnit.h>
#include <RobotAPI/interface/units/WeissHapticUnit.h>
namespace armarx
{
namespace WeissHapticGroup
{
class WeissHapticGroupStatechartContext
: virtual public StatechartContext
{
protected:
class PropertyDefinitions
: public StatechartContextPropertyDefinitions
{
public:
PropertyDefinitions(std::string prefix)
: StatechartContextPropertyDefinitions(prefix)
{
defineOptionalProperty<std::string>("HapticUnitObserverName", "HapticUnitObserver", "Name of the haptic unit observer that should be used");
defineOptionalProperty<std::string>("WeissHapticUnitName", "WeissHapticUnit", "Name of the weiss haptic unit that should be used");
}
}; // class PropertyDefinitions
private:
HapticUnitObserverInterfacePrx hapticObserver;
WeissHapticUnitInterfacePrx weissHapticUnit;
public:
std::string getDefaultName() const
{
return "WeissHapticGroupStatechartContext";
}
virtual void onInitStatechartContext()
{
usingProxy(getProperty<std::string>("HapticUnitObserverName").getValue());
usingProxy(getProperty<std::string>("WeissHapticUnitName").getValue());
}
virtual void onConnectStatechartContext()
{
hapticObserver = getProxy<HapticUnitObserverInterfacePrx>(getProperty<std::string>("HapticUnitObserverName").getValue());
weissHapticUnit = getProxy<WeissHapticUnitInterfacePrx>(getProperty<std::string>("WeissHapticUnitName").getValue());
}
HapticUnitObserverInterfacePrx getHapticObserver() const { return hapticObserver; }
WeissHapticUnitInterfacePrx getWeissHapticUnit() const { return weissHapticUnit; }
virtual PropertyDefinitionsPtr createPropertyDefinitions()
{
return PropertyDefinitionsPtr(new WeissHapticGroupStatechartContext::PropertyDefinitions(getConfigIdentifier()));
}
}; // class WeissHapticGroupStatechartContext
} // namespace WeissHapticGroup
} // namespace armarx
#endif // ARMARX_COMPONENT_ARMARX_WEISSHAPTICGROUP_WEISSHAPTICGROUPSTATECHARTCONTEXT_H
/*
* 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 RobotAPI::WeissHapticGroup
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2015
* @copyright http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#include "WeissHapticSensorTest.h"
#include <RobotAPI/libraries/core/observerfilters/MatrixFilters.h>
#include <RobotAPI/libraries/core/observerfilters/OffsetFilter.h>
using namespace armarx;
using namespace WeissHapticGroup;
// DO NOT EDIT NEXT LINE
WeissHapticSensorTest::SubClassRegistry WeissHapticSensorTest::Registry(WeissHapticSensorTest::GetName(), &WeissHapticSensorTest::CreateInstance);
WeissHapticSensorTest::WeissHapticSensorTest(const XMLStateConstructorParams& stateData) :
XMLStateTemplate<WeissHapticSensorTest>(stateData), WeissHapticSensorTestGeneratedBase<WeissHapticSensorTest>(stateData)
{
}
void WeissHapticSensorTest::onEnter()
{
WeissHapticGroupStatechartContext* context = getContext<WeissHapticGroupStatechartContext>();
HapticUnitObserverInterfacePrx hapticObserver = context->getHapticObserver();
ChannelRegistry channels = hapticObserver->getAvailableChannels(false);
std::map<std::string, DatafieldRefPtr> tactileDatafields_MaximumValueMap;
if(channels.size() == 0)
{
ARMARX_WARNING << "No tactile pads found";
}
else
{
ARMARX_INFO << "Creating tactile channels";
for(std::pair<std::string, ChannelRegistryEntry> pair : channels)
{
std::string tactilePad = pair.first;
DatafieldRefBasePtr matrixDatafield = new DatafieldRef(hapticObserver, tactilePad, "matrix");
DatafieldRefBasePtr matrixNulled = hapticObserver->createFilteredDatafield(DatafieldFilterBasePtr(new filters::OffsetFilter()), matrixDatafield);
DatafieldRefBasePtr matrixMax = hapticObserver->createFilteredDatafield(DatafieldFilterBasePtr(new filters::MatrixMaxFilter()), matrixNulled);
tactileDatafields_MaximumValueMap.insert(std::make_pair(tactilePad, DatafieldRefPtr::dynamicCast(matrixMax)));
}
}
local.setTactileDatafields_MaximumValue(tactileDatafields_MaximumValueMap);
}
void WeissHapticSensorTest::run()
{
std::map<std::string, DatafieldRefPtr> tactileDatafields_MaximumValueMap = local.getTactileDatafields_MaximumValue();
while (!isRunningTaskStopped()) // stop run function if returning true
{
std::stringstream ss;
std::stringstream ssNames;
int max = 0;
for(std::pair<std::string, DatafieldRefPtr> pair : tactileDatafields_MaximumValueMap)
{
std::string tactilePad = pair.first;
DatafieldRefPtr matrixMax = pair.second;
int padMax = (int)matrixMax->getDataField()->getFloat();
ss << padMax << "; ";
ssNames << tactilePad << "; ";
max = std::max(max, padMax);
}
ARMARX_IMPORTANT << "tactile max value: " << max << "; \n\n" << ss.str() << "\n" << ssNames.str();
usleep(10000); // 100ms
}
}
void WeissHapticSensorTest::onBreak()
{
// put your user code for the breaking point here
// execution time should be short (<100ms)
}
void WeissHapticSensorTest::onExit()
{
// put your user code for the exit point here
// execution time should be short (<100ms)
}
// DO NOT EDIT NEXT FUNCTION
XMLStateFactoryBasePtr WeissHapticSensorTest::CreateInstance(XMLStateConstructorParams stateData)
{
return XMLStateFactoryBasePtr(new WeissHapticSensorTest(stateData));
}
#ifndef _ARMARX_XMLUSERCODE_ARMARX_WEISSHAPTICGROUP_WEISSHAPTICSENSORTESTGENERATEDBASE_H
#define _ARMARX_XMLUSERCODE_ARMARX_WEISSHAPTICGROUP_WEISSHAPTICSENSORTESTGENERATEDBASE_H
#include <Core/statechart/xmlstates/XMLState.h>
#include "WeissHapticGroupStatechartContext.generated.h"
#include <Core/observers/ObserverObjectFactories.h>
#include <RobotAPI/interface/units/HapticUnit.h>
#include <RobotAPI/interface/units/WeissHapticUnit.h>
namespace armarx
{
namespace WeissHapticGroup
{
template<typename StateType>
class WeissHapticSensorTestGeneratedBase
: virtual public XMLStateTemplate < StateType >,
public XMLStateFactoryBase
{
protected:
class WeissHapticSensorTestIn
{
private:
WeissHapticSensorTestGeneratedBase<StateType> *parent;
public:
WeissHapticSensorTestIn(WeissHapticSensorTestGeneratedBase<StateType> *parent)
: parent(parent)
{
}
}; // class WeissHapticSensorTestIn
class WeissHapticSensorTestLocal
{
private:
WeissHapticSensorTestGeneratedBase<StateType> *parent;
public:
WeissHapticSensorTestLocal(WeissHapticSensorTestGeneratedBase<StateType> *parent)
: parent(parent)
{
}
public:
std::map<std::string, ::armarx::DatafieldRefPtr> getTactileDatafields_MaximumValue() const
{
return parent->State::getLocal< ::armarx::StringValueMap>("TactileDatafields_MaximumValue")->::armarx::StringValueMap::toStdMap< ::armarx::DatafieldRefPtr>();
}
void setTactileDatafields_MaximumValue(const std::map<std::string, ::armarx::DatafieldRefPtr> & value) const
{
::armarx::StringValueMapPtr container = ::armarx::StringValueMap::FromStdMap< ::armarx::DatafieldRefPtr>(value);
parent->State::setLocal("TactileDatafields_MaximumValue", *container);
}
bool isTactileDatafields_MaximumValueSet() const
{
return parent->State::isLocalParameterSet("TactileDatafields_MaximumValue");
}
}; // class WeissHapticSensorTestLocal
class WeissHapticSensorTestOut
{
private:
WeissHapticSensorTestGeneratedBase<StateType> *parent;
public:
WeissHapticSensorTestOut(WeissHapticSensorTestGeneratedBase<StateType> *parent)
: parent(parent)
{
}
}; // class WeissHapticSensorTestOut
protected:
const WeissHapticSensorTestIn in;
const WeissHapticSensorTestLocal local;
const WeissHapticSensorTestOut out;
public:
WeissHapticSensorTestGeneratedBase(const XMLStateConstructorParams& stateData)
: XMLStateTemplate < StateType > (stateData),
in(WeissHapticSensorTestIn(this)),
local(WeissHapticSensorTestLocal(this)),
out(WeissHapticSensorTestOut(this))
{
}
WeissHapticSensorTestGeneratedBase(const WeissHapticSensorTestGeneratedBase &source)
: IceUtil::Shared(source),
armarx::StateIceBase(source),
armarx::StateBase(source),
armarx::StateController(source),
armarx::State(source),
XMLStateTemplate < StateType > (source),
in(WeissHapticSensorTestIn(this)),
local(WeissHapticSensorTestLocal(this)),
out(WeissHapticSensorTestOut(this))
{
}
public:
HapticUnitObserverInterfacePrx getHapticObserver() const
{
return StateBase::getContext<WeissHapticGroupStatechartContext>()->getHapticObserver();
}
WeissHapticUnitInterfacePrx getWeissHapticUnit() const
{
return StateBase::getContext<WeissHapticGroupStatechartContext>()->getWeissHapticUnit();
}
static std::string GetName()
{
return "WeissHapticSensorTest";
}
void __forceLibLoading()
{
// Do not call this method.
// The sole purpose of this method is to force the compiler/linker to include all libraries.
::armarx::DatafieldRef type1;
}
}; // class WeissHapticSensorTestGeneratedBase
} // namespace WeissHapticGroup
} // namespace armarx
#endif // _ARMARX_XMLUSERCODE_ARMARX_WEISSHAPTICGROUP_WEISSHAPTICSENSORTESTGENERATEDBASE_H
/*
* 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 RobotAPI::WeissHapticGroup
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2015
* @copyright http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
*/
#ifndef _ARMARX_XMLUSERCODE_RobotAPI_WeissHapticGroup_WeissHapticSensorTest_H
#define _ARMARX_XMLUSERCODE_RobotAPI_WeissHapticGroup_WeissHapticSensorTest_H
#include "WeissHapticSensorTest.generated.h"
namespace armarx
{
namespace WeissHapticGroup
{
class WeissHapticSensorTest :
public WeissHapticSensorTestGeneratedBase<WeissHapticSensorTest>
{
public:
WeissHapticSensorTest(const XMLStateConstructorParams& stateData);
// inherited from StateBase
void onEnter();
void run();
void onBreak();
void onExit();
// static functions for AbstractFactory Method
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData);
static SubClassRegistry Registry;
// DO NOT INSERT ANY CLASS MEMBERS,
// use stateparameters instead,
// if classmember are neccessary nonetheless, reset them in onEnter
};
}
}
#endif
<?xml version="1.0" encoding="utf-8"?>
<State version="1.0" name="WeissHapticSensorTest" uuid="B8841E3D-97C6-468F-86D9-6370D5F89BB4" width="800" height="600">
<InputParameters/>
<OutputParameters/>
<LocalParameters>
<Parameter name="TactileDatafields_MaximumValue" type="::armarx::StringValueMapBase(::armarx::DatafieldRefBase)" optional="no"/>
</LocalParameters>
<Substates/>
<Events/>
<Transitions/>
</State>
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