diff --git a/scenarios/GamepadUnit/GamepadUnit.scx b/scenarios/GamepadUnit/GamepadUnit.scx index 8eaf1f00a03426ad38918b3bcdf4d0cfcd47cc34..8f4b0ebf46132fab65b61a378c9f57dd921b761b 100644 --- a/scenarios/GamepadUnit/GamepadUnit.scx +++ b/scenarios/GamepadUnit/GamepadUnit.scx @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> -<scenario name="GamepadUnit" lastChange="2017-03-10.10:16:57" creation="2017-03-09.11:59:13" globalConfigName="./config/global.cfg" package="RobotAPI"> +<scenario name="GamepadUnit" lastChange="2017-03-10.14:30:49" 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"/> + <application name="GamepadControlUnitApp" instance="" package="RobotAPI"/> </scenario> diff --git a/scenarios/GamepadUnit/config/GamepadControlUnitApp.cfg b/scenarios/GamepadUnit/config/GamepadControlUnitApp.cfg new file mode 100644 index 0000000000000000000000000000000000000000..14f5d344e8acb9a277e73cf444848e6cba7dd5a3 --- /dev/null +++ b/scenarios/GamepadUnit/config/GamepadControlUnitApp.cfg @@ -0,0 +1,191 @@ +# ================================================================== +# GamepadControlUnitApp 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.GamepadControlUnit.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: 0 +# - Case sensitivity: no +# - Required: no +ArmarX.GamepadControlUnit.EnableProfiling = 0 + + +# ArmarX.GamepadControlUnit.GamepadTopicName: Name of the Gamepad Topic +# Attributes: +# - Default: GamepadValues +# - Case sensitivity: no +# - Required: no +ArmarX.GamepadControlUnit.GamepadTopicName = GamepadValues + + +# ArmarX.GamepadControlUnit.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: no +# - Required: no +ArmarX.GamepadControlUnit.MinimumLoggingLevel = Undefined + + +# ArmarX.GamepadControlUnit.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: no +# - Required: no +ArmarX.GamepadControlUnit.ObjectName = "" + + +# ArmarX.GamepadControlUnit.PlatformUnitName: Name of the platform unit to use +# Attributes: +# - Default: Armar6IcePlatformUnit +# - Case sensitivity: no +# - Required: no +ArmarX.GamepadControlUnit.PlatformUnitName = Armar6IcePlatformUnit + + +# ArmarX.GamepadControlUnit.ScaleAngle: scaling factor in radian per second +# Attributes: +# - Default: 1 +# - Case sensitivity: no +# - Required: no +ArmarX.GamepadControlUnit.ScaleAngle = 0.1 + + +# ArmarX.GamepadControlUnit.ScaleX: scaling factor in mm per second +# Attributes: +# - Default: 1000 +# - Case sensitivity: no +# - Required: no +ArmarX.GamepadControlUnit.ScaleX = 100 + + +# ArmarX.GamepadControlUnit.ScaleY: scaling factor in mm per second +# Attributes: +# - Default: 1000 +# - Case sensitivity: no +# - Required: no +ArmarX.GamepadControlUnit.ScaleY = 100 + + +# 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 + + + + + diff --git a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp index 0ef985b5d8ba9b22377302e20f92cb23fa5e0f95..2f2c9eaa1f37a516fa4e6c771394eeaf6aa1f408 100644 --- a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp +++ b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp @@ -28,12 +28,18 @@ using namespace armarx; void GamepadControlUnit::onInitComponent() { + ARMARX_INFO << "oninit GamepadControlUnit"; usingProxy(getProperty<std::string>("PlatformUnitName").getValue()); + scaleX = getProperty<float>("ScaleX").getValue(); + scaleY = getProperty<float>("ScaleY").getValue(); + scaleRotation = getProperty<float>("ScaleRotation").getValue(); + ARMARX_INFO << "oninit GamepadControlUnit end"; } void GamepadControlUnit::onConnectComponent() { + ARMARX_INFO << "onConnect GamepadControlUnit"; platformUnitPrx = getTopic<PlatformUnitInterfacePrx>(getProperty<std::string>("PlatformUnitName").getValue()); } @@ -46,17 +52,18 @@ void GamepadControlUnit::onDisconnectComponent() void GamepadControlUnit::onExitComponent() { - + ARMARX_INFO << "exit GamepadControlUnit"; } armarx::PropertyDefinitionsPtr GamepadControlUnit::createPropertyDefinitions() { return armarx::PropertyDefinitionsPtr(new GamepadControlUnitPropertyDefinitions( - getConfigIdentifier())); + getConfigIdentifier())); } void GamepadControlUnit::reportGamepadState(const std::string& device, const std::string& name, const GamepadData& data, const TimestampBasePtr& timestamp, const Ice::Current& c) { - platformUnitPrx->move(data.leftStickX, data.leftStickY, data.rightStickX); + platformUnitPrx->move(data.leftStickX * scaleX, data.leftStickY * scaleY, data.rightStickX * scaleRotation); + ARMARX_INFO << "sending targets" << data.leftStickX* scaleX << " " << data.leftStickY* scaleY << " " << data.rightStickX* scaleRotation; } diff --git a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h index 61f40e572d18081630967f30614541811444d296..d8285522b3f8cc17eb2e917912f43aa8df28434f 100644 --- a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h +++ b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h @@ -45,6 +45,9 @@ namespace armarx //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description"); defineOptionalProperty<std::string>("PlatformUnitName", "Armar6IcePlatformUnit", "Name of the platform unit to use"); defineOptionalProperty<std::string>("GamepadTopicName", "GamepadValues", "Name of the Gamepad Topic"); + defineOptionalProperty<float>("ScaleX", 1000.0f, "scaling factor in mm per second"); + defineOptionalProperty<float>("ScaleY", 1000.0f, "scaling factor in mm per second"); + defineOptionalProperty<float>("ScaleAngle", 1.0f, "scaling factor in radian per second"); } }; @@ -52,11 +55,11 @@ namespace armarx * @defgroup Component-GamepadControlUnit GamepadControlUnit * @ingroup RobotAPI-Components * A description of the component GamepadControlUnit. - * + * * @class GamepadControlUnit * @ingroup Component-GamepadControlUnit * @brief Brief description of class GamepadControlUnit. - * + * * Detailed description of class GamepadControlUnit. */ class GamepadControlUnit : @@ -100,6 +103,9 @@ namespace armarx private: PlatformUnitInterfacePrx platformUnitPrx; + float scaleX; + float scaleY; + float scaleRotation; public: void reportGamepadState(const std::string& device, const std::string& name, const GamepadData& data, const TimestampBasePtr& timestamp, const Ice::Current& c);