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

added GamepadUnit

parent c9e0b22f
No related branches found
No related tags found
No related merge requests found
Showing
with 988 additions and 1 deletion
<?xml version="1.0" encoding="utf-8"?>
<scenario name="GamepadUnit" lastChange="2017-03-09.11:59:19" creation="2017-03-09.11:59:13" globalConfigName="./config/global.cfg" package="RobotAPI">
<application name="GamepadUnitApp" instance="" package="RobotAPI"/>
<application name="GamepadUnitObserverApp" instance="" package="RobotAPI"/>
</scenario>
# ==================================================================
# GamepadUnitApp properties
# ==================================================================
# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List.
# Attributes:
# - Default: Default value not mapped.
# - Case sensitivity: no
# - Required: no
# ArmarX.AdditionalPackages = Default value not mapped.
# ArmarX.ApplicationName: Application name
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ApplicationName = ""
# ArmarX.CachePath: Path for cache files
# Attributes:
# - Default: ${HOME}/.armarx/mongo/.cache
# - Case sensitivity: no
# - Required: no
# ArmarX.CachePath = ${HOME}/.armarx/mongo/.cache
# ArmarX.Config: Comma-separated list of configuration files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.Config = ""
# ArmarX.DataPath: Semicolon-separated search list for data files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DataPath = ""
# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'.
# Attributes:
# - Default: Default value not mapped.
# - Case sensitivity: no
# - Required: no
# ArmarX.DefaultPackages = Default value not mapped.
# 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.DisableLogging: Turn logging off in whole application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.DisableLogging = 0
# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.EnableProfiling = 0
# ArmarX.GamepadUnit.EnableProfiling: enable profiler which is used for logging performance events
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnit.EnableProfiling = 0
# ArmarX.GamepadUnit.GamepadTopicName: Name of the Gamepad Topic
# Attributes:
# - Default: GamepadValues
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnit.GamepadTopicName = GamepadValues
# ArmarX.GamepadUnit.MinimumLoggingLevel: Local logging level only for this component
# Attributes:
# - Default: Undefined
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnit.MinimumLoggingLevel = Undefined
# ArmarX.GamepadUnit.ObjectName: Name of IceGrid well-known object
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnit.ObjectName = ""
# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog
# Attributes:
# - Default: 1
# - Case sensitivity: no
# - Required: no
# ArmarX.RedirectStdout = 1
# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles)
# Attributes:
# - Default: 3000
# - Case sensitivity: no
# - Required: no
# ArmarX.RemoteHandlesDeletionTimeout = 3000
# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger.
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.StartDebuggerOnCrash = 0
# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes.
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.TopicSuffix = ""
# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator)
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.UseTimeServer = 0
# ArmarX.Verbosity: Global logging level for whole application
# Attributes:
# - Default: Info
# - Case sensitivity: no
# - Required: no
# ArmarX.Verbosity = Info
# Ice.Config: Custom Property
# Attributes:
# - Default: ::NOT_DEFINED::
# - Case sensitivity: no
# - Required: no
# Ice.Config = ::NOT_DEFINED::
# ==================================================================
# GamepadUnitObserverApp properties
# ==================================================================
# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List.
# Attributes:
# - Default: Default value not mapped.
# - Case sensitivity: no
# - Required: no
# ArmarX.AdditionalPackages = Default value not mapped.
# ArmarX.ApplicationName: Application name
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.ApplicationName = ""
# ArmarX.CachePath: Path for cache files
# Attributes:
# - Default: ${HOME}/.armarx/mongo/.cache
# - Case sensitivity: no
# - Required: no
# ArmarX.CachePath = ${HOME}/.armarx/mongo/.cache
# ArmarX.Config: Comma-separated list of configuration files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.Config = ""
# ArmarX.DataPath: Semicolon-separated search list for data files
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.DataPath = ""
# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'.
# Attributes:
# - Default: Default value not mapped.
# - Case sensitivity: no
# - Required: no
# ArmarX.DefaultPackages = Default value not mapped.
# 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.DisableLogging: Turn logging off in whole application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.DisableLogging = 0
# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.EnableProfiling = 0
# ArmarX.GamepadUnitObserver.CreateUpdateFrequenciesChannel: If true, an additional channel is created that shows the update frequency of every other channel in that observer.
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnitObserver.CreateUpdateFrequenciesChannel = 0
# ArmarX.GamepadUnitObserver.DebugDrawerTopic: Name of the DebugDrawerTopic
# Attributes:
# - Default: DebugDrawerUpdates
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnitObserver.DebugDrawerTopic = DebugDrawerUpdates
# ArmarX.GamepadUnitObserver.EnableProfiling: enable profiler which is used for logging performance events
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnitObserver.EnableProfiling = 0
# ArmarX.GamepadUnitObserver.GamepadTopicName: Name of the Gamepad Topic
# Attributes:
# - Default: GamepadValues
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnitObserver.GamepadTopicName = GamepadValues
# ArmarX.GamepadUnitObserver.MaxHistoryRecordFrequency: The Observer history is written with this maximum frequency. Everything faster is being skipped.
# Attributes:
# - Default: 50
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnitObserver.MaxHistoryRecordFrequency = 50
# ArmarX.GamepadUnitObserver.MaxHistorySize: Maximum number of entries in the Observer history
# Attributes:
# - Default: 5000
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnitObserver.MaxHistorySize = 5000
# ArmarX.GamepadUnitObserver.MinimumLoggingLevel: Local logging level only for this component
# Attributes:
# - Default: Undefined
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnitObserver.MinimumLoggingLevel = Undefined
# ArmarX.GamepadUnitObserver.ObjectName: Name of IceGrid well-known object
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.GamepadUnitObserver.ObjectName = ""
# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog
# Attributes:
# - Default: 1
# - Case sensitivity: no
# - Required: no
# ArmarX.RedirectStdout = 1
# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles)
# Attributes:
# - Default: 3000
# - Case sensitivity: no
# - Required: no
# ArmarX.RemoteHandlesDeletionTimeout = 3000
# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger.
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.StartDebuggerOnCrash = 0
# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes.
# Attributes:
# - Default: ""
# - Case sensitivity: no
# - Required: no
# ArmarX.TopicSuffix = ""
# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator)
# Attributes:
# - Default: 0
# - Case sensitivity: no
# - Required: no
# ArmarX.UseTimeServer = 0
# ArmarX.Verbosity: Global logging level for whole application
# Attributes:
# - Default: Info
# - Case sensitivity: no
# - Required: no
# ArmarX.Verbosity = Info
# Ice.Config: Custom Property
# Attributes:
# - Default: ::NOT_DEFINED::
# - Case sensitivity: no
# - Required: no
# Ice.Config = ::NOT_DEFINED::
# ==================================================================
# Global Config from Scenario GamepadUnit
# ==================================================================
...@@ -26,4 +26,6 @@ add_subdirectory(OrientedTactileSensorUnit) ...@@ -26,4 +26,6 @@ add_subdirectory(OrientedTactileSensorUnit)
add_subdirectory(OrientedTactileSensorUnitObserver) add_subdirectory(OrientedTactileSensorUnitObserver)
add_subdirectory(OptoForceUnit) add_subdirectory(OptoForceUnit)
add_subdirectory(OptoForceUnitObserver) add_subdirectory(OptoForceUnitObserver)
\ No newline at end of file add_subdirectory(GamepadUnit)
add_subdirectory(GamepadUnitObserver)
\ No newline at end of file
armarx_component_set_name("GamepadUnitApp")
#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()
set(COMPONENT_LIBS
ArmarXCoreInterfaces
ArmarXCore
GamepadUnit
)
set(EXE_SOURCE main.cpp)
armarx_add_component_executable("${EXE_SOURCE}")
/*
* 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::application::GamepadUnit
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2017
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include <RobotAPI/drivers/GamepadUnit/GamepadUnit.h>
#include <ArmarXCore/core/application/Application.h>
#include <ArmarXCore/core/Component.h>
#include <ArmarXCore/core/logging/Logging.h>
int main(int argc, char* argv[])
{
return armarx::runSimpleComponentApp < armarx::GamepadUnit > (argc, argv, "GamepadUnit");
}
armarx_component_set_name("GamepadUnitObserverApp")
#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()
set(COMPONENT_LIBS
ArmarXCoreInterfaces
ArmarXCore
RobotAPIUnits
)
set(EXE_SOURCE main.cpp)
armarx_add_component_executable("${EXE_SOURCE}")
/*
* 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::application::GamepadUnitObserver
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2017
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include <RobotAPI/components/units/GamepadUnitObserver.h>
#include <ArmarXCore/core/application/Application.h>
#include <ArmarXCore/core/Component.h>
#include <ArmarXCore/core/logging/Logging.h>
int main(int argc, char* argv[])
{
return armarx::runSimpleComponentApp < armarx::GamepadUnitObserver > (argc, argv, "GamepadUnitObserver");
}
...@@ -34,6 +34,7 @@ set(LIB_HEADERS ...@@ -34,6 +34,7 @@ set(LIB_HEADERS
InertialMeasurementUnitObserver.h InertialMeasurementUnitObserver.h
OptoForceUnitObserver.h OptoForceUnitObserver.h
OrientedTactileSensorUnitObserver.h OrientedTactileSensorUnitObserver.h
GamepadUnitObserver.h
TCPControlUnit.h TCPControlUnit.h
TCPControlUnitObserver.h TCPControlUnitObserver.h
...@@ -61,6 +62,7 @@ set(LIB_FILES ...@@ -61,6 +62,7 @@ set(LIB_FILES
InertialMeasurementUnitObserver.cpp InertialMeasurementUnitObserver.cpp
OptoForceUnitObserver.cpp OptoForceUnitObserver.cpp
OrientedTactileSensorUnitObserver.cpp OrientedTactileSensorUnitObserver.cpp
GamepadUnitObserver.cpp
TCPControlUnit.cpp TCPControlUnit.cpp
TCPControlUnitObserver.cpp TCPControlUnitObserver.cpp
......
/*
* This file is part of ArmarX.
*
* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
*
* 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
* @author
* @date
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include "GamepadUnitObserver.h"
#include <ArmarXCore/observers/checks/ConditionCheckEquals.h>
#include <ArmarXCore/observers/checks/ConditionCheckLarger.h>
#include <ArmarXCore/observers/checks/ConditionCheckSmaller.h>
#include <ArmarXCore/observers/checks/ConditionCheckUpdated.h>
#include <RobotAPI/libraries/core/Pose.h>
#include <ArmarXCore/observers/variant/TimestampVariant.h>
using namespace armarx;
void GamepadUnitObserver::onInitObserver()
{
usingTopic(getProperty<std::string>("GamepadTopicName").getValue());
offerConditionCheck("updated", new ConditionCheckUpdated());
offerConditionCheck("larger", new ConditionCheckLarger());
offerConditionCheck("equals", new ConditionCheckEquals());
offerConditionCheck("smaller", new ConditionCheckSmaller());
offeringTopic(getProperty<std::string>("DebugDrawerTopic").getValue());
}
void GamepadUnitObserver::onConnectObserver()
{
debugDrawerPrx = getTopic<DebugDrawerInterfacePrx>(getProperty<std::string>("DebugDrawerTopic").getValue());
}
void GamepadUnitObserver::onExitObserver()
{
debugDrawerPrx->removePoseVisu("IMU", "orientation");
debugDrawerPrx->removeLineVisu("IMU", "acceleration");
}
void GamepadUnitObserver::reportAnalogSticks(const std::string& device, const std::string& name, const AnalogStickData& values, const TimestampBasePtr& timestamp, const Ice::Current& c)
{
ScopedLock lock(dataMutex);
TimestampVariantPtr timestampPtr = TimestampVariantPtr::dynamicCast(timestamp);
if (!existsChannel(device))
{
offerChannel(device, "Gamepad data");
}
offerOrUpdateDataField(device, "analog_x", Variant(values.x), "X value of the analog sticks");
offerOrUpdateDataField(device, "analog_y", Variant(values.y), "Y value of the analog sticks");
offerOrUpdateDataField(device, "analog_z", Variant(values.z), "Z value of the analog sticks");
offerOrUpdateDataField(device, "analog_a", Variant(values.a), "A value of the analog sticks");
updateChannel(device);
}
PropertyDefinitionsPtr GamepadUnitObserver::createPropertyDefinitions()
{
return PropertyDefinitionsPtr(new GamepadUnitObserverPropertyDefinitions(getConfigIdentifier()));
}
/*
* This file is part of ArmarX.
*
* Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
*
* 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::units
* @author David Schiebener <schiebener at kit dot edu>
* @date 2014
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#ifndef _ARMARX_ROBOTAPI_GAMEPAD_OBSERVER_H
#define _ARMARX_ROBOTAPI_GAMEPAD_OBSERVER_H
#include <RobotAPI/interface/units/GamepadUnit.h>
#include <ArmarXCore/observers/Observer.h>
#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
#include <RobotAPI/libraries/core/Pose.h>
namespace armarx
{
/**
* \class GamepadUnitObserverPropertyDefinitions
* \brief
*/
class GamepadUnitObserverPropertyDefinitions:
public ObserverPropertyDefinitions
{
public:
GamepadUnitObserverPropertyDefinitions(std::string prefix):
ObserverPropertyDefinitions(prefix)
{
defineOptionalProperty<std::string>("GamepadTopicName", "GamepadValues", "Name of the Gamepad Topic");
defineOptionalProperty<std::string>("DebugDrawerTopic", "DebugDrawerUpdates", "Name of the DebugDrawerTopic");
}
};
/**
* \class GamepadUnitObserver
* \ingroup RobotAPI-SensorActorUnits-observers
* \brief Observer monitoring @IMU sensor values
*
* The GamepadUnitObserver monitors @IMU sensor values published by GamepadUnit-implementations and offers condition checks on these values.
* Available condition checks are: *updated*, *larger*, *equals* and *smaller*.
*/
class GamepadUnitObserver :
virtual public Observer,
virtual public GamepadUnitObserverInterface
{
public:
GamepadUnitObserver() {}
virtual std::string getDefaultName() const
{
return "GamepadUnitObserver";
}
virtual void onInitObserver();
virtual void onConnectObserver();
virtual void onExitObserver();
void reportAnalogSticks(const std::string& device, const std::string& name, const AnalogStickData& values, const TimestampBasePtr& timestamp, const Ice::Current& c = ::Ice::Current());
/**
* @see PropertyUser::createPropertyDefinitions()
*/
virtual PropertyDefinitionsPtr createPropertyDefinitions();
private:
Mutex dataMutex;
DebugDrawerInterfacePrx debugDrawerPrx;
};
}
#endif
...@@ -2,4 +2,5 @@ add_subdirectory(WeissHapticSensor) ...@@ -2,4 +2,5 @@ add_subdirectory(WeissHapticSensor)
add_subdirectory(XsensIMU) add_subdirectory(XsensIMU)
add_subdirectory(OptoForceUnit) add_subdirectory(OptoForceUnit)
add_subdirectory(OrientedTactileSensor) add_subdirectory(OrientedTactileSensor)
add_subdirectory(GamepadUnit)
armarx_component_set_name("GamepadUnit")
#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()
set(COMPONENT_LIBS ArmarXCoreInterfaces ArmarXCore ArmarXCoreEigen3Variants RobotAPIInterfaces)
set(SOURCES
./GamepadUnit.cpp
#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.cpp
)
set(HEADERS
./GamepadUnit.h
#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.h
)
armarx_add_component("${SOURCES}" "${HEADERS}")
# add unit tests
add_subdirectory(test)
/*
* 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::ArmarXObjects::GamepadUnit
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2017
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include "GamepadUnit.h"
#include <ArmarXCore/observers/variant/TimestampVariant.h>
using namespace armarx;
void GamepadUnit::onInitComponent()
{
offeringTopic(getProperty<std::string>("GamepadTopicName").getValue());
readTask = new RunningTask<GamepadUnit>(this, &GamepadUnit::run, "GamepadUnit");
}
void GamepadUnit::onConnectComponent()
{
topicPrx = getTopic<GamepadUnitListenerPrx>(getProperty<std::string>("GamepadTopicName").getValue());
readTask->start();
}
void GamepadUnit::run()
{
while(readTask->isRunning())
{
IceUtil::Time now = IceUtil::Time::now();
TimestampVariantPtr nowTimestamp = new TimestampVariant(now);
AnalogStickData data;
data.x = std::cos(now.toSecondsDouble());
data.y = std::sin(now.toSecondsDouble());
data.z = 0;
data.a = 0;
topicPrx->reportAnalogSticks("DeviceNameHere", "NameHere", data, nowTimestamp);
usleep(10000); // 10ms
}
}
void GamepadUnit::onDisconnectComponent()
{
}
void GamepadUnit::onExitComponent()
{
}
armarx::PropertyDefinitionsPtr GamepadUnit::createPropertyDefinitions()
{
return armarx::PropertyDefinitionsPtr(new GamepadUnitPropertyDefinitions(
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 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::ArmarXObjects::GamepadUnit
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2017
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#ifndef _ARMARX_COMPONENT_RobotAPI_GamepadUnit_H
#define _ARMARX_COMPONENT_RobotAPI_GamepadUnit_H
#include <ArmarXCore/core/Component.h>
#include <ArmarXCore/core/services/tasks/RunningTask.h>
#include <RobotAPI/interface/units/GamepadUnit.h>
namespace armarx
{
/**
* @class GamepadUnitPropertyDefinitions
* @brief
*/
class GamepadUnitPropertyDefinitions:
public armarx::ComponentPropertyDefinitions
{
public:
GamepadUnitPropertyDefinitions(std::string prefix):
armarx::ComponentPropertyDefinitions(prefix)
{
//defineRequiredProperty<std::string>("PropertyName", "Description");
//defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
defineOptionalProperty<std::string>("GamepadTopicName", "GamepadValues", "Name of the Gamepad Topic");
}
};
/**
* @defgroup Component-GamepadUnit GamepadUnit
* @ingroup RobotAPI-Components
* A description of the component GamepadUnit.
*
* @class GamepadUnit
* @ingroup Component-GamepadUnit
* @brief Brief description of class GamepadUnit.
*
* Detailed description of class GamepadUnit.
*/
class GamepadUnit :
virtual public armarx::Component
{
public:
/**
* @see armarx::ManagedIceObject::getDefaultName()
*/
virtual std::string getDefaultName() const
{
return "GamepadUnit";
}
protected:
/**
* @see armarx::ManagedIceObject::onInitComponent()
*/
virtual void onInitComponent();
/**
* @see armarx::ManagedIceObject::onConnectComponent()
*/
virtual void onConnectComponent();
/**
* @see armarx::ManagedIceObject::onDisconnectComponent()
*/
virtual void onDisconnectComponent();
/**
* @see armarx::ManagedIceObject::onExitComponent()
*/
virtual void onExitComponent();
/**
* @see PropertyUser::createPropertyDefinitions()
*/
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions();
private:
GamepadUnitListenerPrx topicPrx;
RunningTask<GamepadUnit>::pointer_type readTask;
void run();
};
}
#endif
# Libs required for the tests
SET(LIBS ${LIBS} ArmarXCore GamepadUnit)
armarx_add_test(GamepadUnitTest GamepadUnitTest.cpp "${LIBS}")
\ No newline at end of file
/*
* 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::ArmarXObjects::GamepadUnit
* @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
* @date 2017
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#define BOOST_TEST_MODULE RobotAPI::ArmarXObjects::GamepadUnit
#define ARMARX_BOOST_TEST
#include <RobotAPI/Test.h>
#include <RobotAPI/drivers/GamepadUnit/GamepadUnit.h>
#include <iostream>
BOOST_AUTO_TEST_CASE(testExample)
{
armarx::GamepadUnit instance;
BOOST_CHECK_EQUAL(true, true);
}
...@@ -36,6 +36,7 @@ set(SLICE_FILES ...@@ -36,6 +36,7 @@ set(SLICE_FILES
units/UnitInterface.ice units/UnitInterface.ice
units/ATINetFTUnit.ice units/ATINetFTUnit.ice
units/OrientedTactileSensorUnit.ice units/OrientedTactileSensorUnit.ice
units/GamepadUnit.ice
components/ViewSelectionInterface.ice components/ViewSelectionInterface.ice
......
/*
* This file is part of ArmarX.
*
* Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
*
* 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
* @author Markus Grotz <markus dot grotz at kit dot edu>
* @date 2015
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#ifndef _ARMARX_ROBOTAPI_UNITS_GAMEPAD_SLICE_
#define _ARMARX_ROBOTAPI_UNITS_GAMEPAD_SLICE_
#include <RobotAPI/interface/units/UnitInterface.ice>
#include <RobotAPI/interface/core/RobotState.ice>
#include <ArmarXCore/interface/core/UserException.ice>
#include <ArmarXCore/interface/core/BasicTypes.ice>
#include <ArmarXCore/interface/observers/VariantBase.ice>
#include <ArmarXCore/interface/observers/Matrix.ice>
#include <ArmarXCore/interface/observers/Timestamp.ice>
#include <ArmarXCore/interface/observers/ObserverInterface.ice>
module armarx
{
struct AnalogStickData {
float x;
float y;
float z;
float a;
};
interface GamepadUnitInterface extends armarx::SensorActorUnitInterface
{
};
interface GamepadUnitListener
{
void reportAnalogSticks(string device, string name, AnalogStickData values, TimestampBase timestamp);
};
/**
* Implements an interface to an GamepadUnitObserver.
**/
interface GamepadUnitObserverInterface extends ObserverInterface, GamepadUnitListener
{
};
};
#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