From 808b15d70dcdc71b0682a76ab63917dcae39072c Mon Sep 17 00:00:00 2001
From: Markus Swarowsky <markus.swarowsky@student.kit.edu>
Date: Fri, 10 Mar 2017 17:53:26 +0100
Subject: [PATCH] fixed everything to use the Gamepad to control the ARMAR-6-SH
 Platform

---
 scenarios/GamepadUnit/GamepadUnit.scx             |  2 +-
 .../GamepadUnit/config/GamepadControlUnitApp.cfg  |  6 +++---
 scenarios/GamepadUnit/config/GamepadUnitApp.cfg   |  2 +-
 .../GamepadUnit/config/GamepadUnitObserverApp.cfg |  8 --------
 .../components/GamepadControlUnit/CMakeLists.txt  |  2 +-
 .../GamepadControlUnit/GamepadControlUnit.cpp     | 15 +++++++++++----
 .../GamepadControlUnit/GamepadControlUnit.h       |  3 ++-
 .../RobotAPI/drivers/GamepadUnit/GamepadUnit.cpp  |  2 +-
 8 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/scenarios/GamepadUnit/GamepadUnit.scx b/scenarios/GamepadUnit/GamepadUnit.scx
index 8f4b0ebf4..3bb057775 100644
--- a/scenarios/GamepadUnit/GamepadUnit.scx
+++ b/scenarios/GamepadUnit/GamepadUnit.scx
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<scenario name="GamepadUnit" lastChange="2017-03-10.14:30:49" creation="2017-03-09.11:59:13" globalConfigName="./config/global.cfg" package="RobotAPI">
+<scenario name="GamepadUnit" lastChange="2017-03-10.16:38:15" 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"/>
diff --git a/scenarios/GamepadUnit/config/GamepadControlUnitApp.cfg b/scenarios/GamepadUnit/config/GamepadControlUnitApp.cfg
index 14f5d344e..568d1a3ff 100644
--- a/scenarios/GamepadUnit/config/GamepadControlUnitApp.cfg
+++ b/scenarios/GamepadUnit/config/GamepadControlUnitApp.cfg
@@ -119,7 +119,7 @@ ArmarX.GamepadControlUnit.PlatformUnitName = Armar6IcePlatformUnit
 #  - Default:            1
 #  - Case sensitivity:   no
 #  - Required:           no
-ArmarX.GamepadControlUnit.ScaleAngle = 0.1
+ArmarX.GamepadControlUnit.ScaleAngle = -1
 
 
 # ArmarX.GamepadControlUnit.ScaleX:  scaling factor in mm per second
@@ -127,7 +127,7 @@ ArmarX.GamepadControlUnit.ScaleAngle = 0.1
 #  - Default:            1000
 #  - Case sensitivity:   no
 #  - Required:           no
-ArmarX.GamepadControlUnit.ScaleX = 100
+ArmarX.GamepadControlUnit.ScaleX = 1000
 
 
 # ArmarX.GamepadControlUnit.ScaleY:  scaling factor in mm per second
@@ -135,7 +135,7 @@ ArmarX.GamepadControlUnit.ScaleX = 100
 #  - Default:            1000
 #  - Case sensitivity:   no
 #  - Required:           no
-ArmarX.GamepadControlUnit.ScaleY = 100
+ArmarX.GamepadControlUnit.ScaleY = -1000
 
 
 # ArmarX.RedirectStdout:  Redirect std::cout and std::cerr to ArmarXLog
diff --git a/scenarios/GamepadUnit/config/GamepadUnitApp.cfg b/scenarios/GamepadUnit/config/GamepadUnitApp.cfg
index 7d704c0ef..d30f64a82 100644
--- a/scenarios/GamepadUnit/config/GamepadUnitApp.cfg
+++ b/scenarios/GamepadUnit/config/GamepadUnitApp.cfg
@@ -87,7 +87,7 @@
 #  - Default:            /dev/input/js2
 #  - Case sensitivity:   no
 #  - Required:           no
-# ArmarX.GamepadUnit.GamepadDeviceName = /dev/input/js2
+ArmarX.GamepadUnit.GamepadDeviceName = /dev/input/js0
 
 
 # ArmarX.GamepadUnit.GamepadTopicName:  Name of the Gamepad Topic
diff --git a/scenarios/GamepadUnit/config/GamepadUnitObserverApp.cfg b/scenarios/GamepadUnit/config/GamepadUnitObserverApp.cfg
index 0d1aa7e7e..27e3b329d 100644
--- a/scenarios/GamepadUnit/config/GamepadUnitObserverApp.cfg
+++ b/scenarios/GamepadUnit/config/GamepadUnitObserverApp.cfg
@@ -74,14 +74,6 @@
 # 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
diff --git a/source/RobotAPI/components/GamepadControlUnit/CMakeLists.txt b/source/RobotAPI/components/GamepadControlUnit/CMakeLists.txt
index 146c18bf6..b78b5d099 100644
--- a/source/RobotAPI/components/GamepadControlUnit/CMakeLists.txt
+++ b/source/RobotAPI/components/GamepadControlUnit/CMakeLists.txt
@@ -9,7 +9,7 @@ armarx_component_set_name("GamepadControlUnit")
 #    include_directories(${MyLib_INCLUDE_DIRS})
 #endif()
 
-set(COMPONENT_LIBS ArmarXCoreInterfaces ArmarXCore RobotAPIInterfaces)
+set(COMPONENT_LIBS ArmarXCoreInterfaces ArmarXCore ArmarXCoreObservers RobotAPIInterfaces )
 
 set(SOURCES
 ./GamepadControlUnit.cpp
diff --git a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp
index 2f2c9eaa1..7d29b0a42 100644
--- a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp
+++ b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp
@@ -22,6 +22,9 @@
 
 #include "GamepadControlUnit.h"
 
+#include <ArmarXCore/observers/variant/TimestampVariant.h>
+
+
 
 using namespace armarx;
 
@@ -30,9 +33,12 @@ void GamepadControlUnit::onInitComponent()
 {
     ARMARX_INFO << "oninit GamepadControlUnit";
     usingProxy(getProperty<std::string>("PlatformUnitName").getValue());
+    usingTopic(getProperty<std::string>("GamepadTopicName").getValue());
+
+
     scaleX = getProperty<float>("ScaleX").getValue();
     scaleY = getProperty<float>("ScaleY").getValue();
-    scaleRotation = getProperty<float>("ScaleRotation").getValue();
+    scaleRotation = getProperty<float>("ScaleAngle").getValue();
     ARMARX_INFO << "oninit GamepadControlUnit end";
 }
 
@@ -40,7 +46,7 @@ void GamepadControlUnit::onInitComponent()
 void GamepadControlUnit::onConnectComponent()
 {
     ARMARX_INFO << "onConnect GamepadControlUnit";
-    platformUnitPrx = getTopic<PlatformUnitInterfacePrx>(getProperty<std::string>("PlatformUnitName").getValue());
+    platformUnitPrx = getProxy<PlatformUnitInterfacePrx>(getProperty<std::string>("PlatformUnitName").getValue());
 }
 
 
@@ -63,7 +69,8 @@ armarx::PropertyDefinitionsPtr GamepadControlUnit::createPropertyDefinitions()
 
 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 * scaleX, data.leftStickY * scaleY, data.rightStickX * scaleRotation);
-    ARMARX_INFO << "sending targets" << data.leftStickX* scaleX << " " << data.leftStickY* scaleY << " " << data.rightStickX* scaleRotation;
+    //scales are for the robot axis
+    platformUnitPrx->move(data.leftStickY  * scaleX, data. leftStickX  * 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 d8285522b..a4b0f6c99 100644
--- a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h
+++ b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h
@@ -108,7 +108,8 @@ namespace armarx
         float scaleRotation;
 
     public:
-        void reportGamepadState(const std::string& device, const std::string& name, const GamepadData& data, const TimestampBasePtr& timestamp, const Ice::Current& c);
+        void reportGamepadState(const std::string& device, const std::string& name, const GamepadData& data,
+                                const TimestampBasePtr& timestamp, const Ice::Current& c) override;
 
     };
 }
diff --git a/source/RobotAPI/drivers/GamepadUnit/GamepadUnit.cpp b/source/RobotAPI/drivers/GamepadUnit/GamepadUnit.cpp
index f844a6006..a840e0c06 100644
--- a/source/RobotAPI/drivers/GamepadUnit/GamepadUnit.cpp
+++ b/source/RobotAPI/drivers/GamepadUnit/GamepadUnit.cpp
@@ -95,7 +95,7 @@ void GamepadUnit::run()
         data.leftStickButton = js.buttonsPressed[9];
         data.rightStickButton = js.buttonsPressed[10];
 
-        //ARMARX_IMPORTANT << "left x (integer): " << js.axis[0] << " left x (float): " << data.leftStickX;
+        ARMARX_IMPORTANT << "left x (integer): " << js.axis[0] << " left x (float): " << data.leftStickX;
 
         topicPrx->reportGamepadState(deviceName, js.name, data, nowTimestamp);
 
-- 
GitLab