Skip to content
Snippets Groups Projects
Commit 808b15d7 authored by Markus Swarowsky's avatar Markus Swarowsky
Browse files

fixed everything to use the Gamepad to control the ARMAR-6-SH Platform

parent 4361712b
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8"?> <?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="GamepadUnitApp" instance="" package="RobotAPI"/>
<application name="GamepadUnitObserverApp" instance="" package="RobotAPI"/> <application name="GamepadUnitObserverApp" instance="" package="RobotAPI"/>
<application name="GamepadControlUnitApp" instance="" package="RobotAPI"/> <application name="GamepadControlUnitApp" instance="" package="RobotAPI"/>
......
...@@ -119,7 +119,7 @@ ArmarX.GamepadControlUnit.PlatformUnitName = Armar6IcePlatformUnit ...@@ -119,7 +119,7 @@ ArmarX.GamepadControlUnit.PlatformUnitName = Armar6IcePlatformUnit
# - Default: 1 # - Default: 1
# - Case sensitivity: no # - Case sensitivity: no
# - Required: no # - Required: no
ArmarX.GamepadControlUnit.ScaleAngle = 0.1 ArmarX.GamepadControlUnit.ScaleAngle = -1
# ArmarX.GamepadControlUnit.ScaleX: scaling factor in mm per second # ArmarX.GamepadControlUnit.ScaleX: scaling factor in mm per second
...@@ -127,7 +127,7 @@ ArmarX.GamepadControlUnit.ScaleAngle = 0.1 ...@@ -127,7 +127,7 @@ ArmarX.GamepadControlUnit.ScaleAngle = 0.1
# - Default: 1000 # - Default: 1000
# - Case sensitivity: no # - Case sensitivity: no
# - Required: no # - Required: no
ArmarX.GamepadControlUnit.ScaleX = 100 ArmarX.GamepadControlUnit.ScaleX = 1000
# ArmarX.GamepadControlUnit.ScaleY: scaling factor in mm per second # ArmarX.GamepadControlUnit.ScaleY: scaling factor in mm per second
...@@ -135,7 +135,7 @@ ArmarX.GamepadControlUnit.ScaleX = 100 ...@@ -135,7 +135,7 @@ ArmarX.GamepadControlUnit.ScaleX = 100
# - Default: 1000 # - Default: 1000
# - Case sensitivity: no # - Case sensitivity: no
# - Required: no # - Required: no
ArmarX.GamepadControlUnit.ScaleY = 100 ArmarX.GamepadControlUnit.ScaleY = -1000
# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog # ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
# - Default: /dev/input/js2 # - Default: /dev/input/js2
# - Case sensitivity: no # - Case sensitivity: no
# - Required: no # - Required: no
# ArmarX.GamepadUnit.GamepadDeviceName = /dev/input/js2 ArmarX.GamepadUnit.GamepadDeviceName = /dev/input/js0
# ArmarX.GamepadUnit.GamepadTopicName: Name of the Gamepad Topic # ArmarX.GamepadUnit.GamepadTopicName: Name of the Gamepad Topic
......
...@@ -74,14 +74,6 @@ ...@@ -74,14 +74,6 @@
# ArmarX.EnableProfiling = 0 # 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 # ArmarX.GamepadUnitObserver.DebugDrawerTopic: Name of the DebugDrawerTopic
# Attributes: # Attributes:
# - Default: DebugDrawerUpdates # - Default: DebugDrawerUpdates
......
...@@ -9,7 +9,7 @@ armarx_component_set_name("GamepadControlUnit") ...@@ -9,7 +9,7 @@ armarx_component_set_name("GamepadControlUnit")
# include_directories(${MyLib_INCLUDE_DIRS}) # include_directories(${MyLib_INCLUDE_DIRS})
#endif() #endif()
set(COMPONENT_LIBS ArmarXCoreInterfaces ArmarXCore RobotAPIInterfaces) set(COMPONENT_LIBS ArmarXCoreInterfaces ArmarXCore ArmarXCoreObservers RobotAPIInterfaces )
set(SOURCES set(SOURCES
./GamepadControlUnit.cpp ./GamepadControlUnit.cpp
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#include "GamepadControlUnit.h" #include "GamepadControlUnit.h"
#include <ArmarXCore/observers/variant/TimestampVariant.h>
using namespace armarx; using namespace armarx;
...@@ -30,9 +33,12 @@ void GamepadControlUnit::onInitComponent() ...@@ -30,9 +33,12 @@ void GamepadControlUnit::onInitComponent()
{ {
ARMARX_INFO << "oninit GamepadControlUnit"; ARMARX_INFO << "oninit GamepadControlUnit";
usingProxy(getProperty<std::string>("PlatformUnitName").getValue()); usingProxy(getProperty<std::string>("PlatformUnitName").getValue());
usingTopic(getProperty<std::string>("GamepadTopicName").getValue());
scaleX = getProperty<float>("ScaleX").getValue(); scaleX = getProperty<float>("ScaleX").getValue();
scaleY = getProperty<float>("ScaleY").getValue(); scaleY = getProperty<float>("ScaleY").getValue();
scaleRotation = getProperty<float>("ScaleRotation").getValue(); scaleRotation = getProperty<float>("ScaleAngle").getValue();
ARMARX_INFO << "oninit GamepadControlUnit end"; ARMARX_INFO << "oninit GamepadControlUnit end";
} }
...@@ -40,7 +46,7 @@ void GamepadControlUnit::onInitComponent() ...@@ -40,7 +46,7 @@ void GamepadControlUnit::onInitComponent()
void GamepadControlUnit::onConnectComponent() void GamepadControlUnit::onConnectComponent()
{ {
ARMARX_INFO << "onConnect GamepadControlUnit"; 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() ...@@ -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) 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); //scales are for the robot axis
ARMARX_INFO << "sending targets" << data.leftStickX* scaleX << " " << data.leftStickY* scaleY << " " << data.rightStickX* scaleRotation; platformUnitPrx->move(data.leftStickY * scaleX, data. leftStickX * scaleY, data.rightStickX * scaleRotation);
//ARMARX_INFO << "sending targets" << data.leftStickX* scaleX << " " << data.leftStickY* scaleY << " " << data.rightStickX* scaleRotation;
} }
...@@ -108,7 +108,8 @@ namespace armarx ...@@ -108,7 +108,8 @@ namespace armarx
float scaleRotation; float scaleRotation;
public: 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;
}; };
} }
......
...@@ -95,7 +95,7 @@ void GamepadUnit::run() ...@@ -95,7 +95,7 @@ void GamepadUnit::run()
data.leftStickButton = js.buttonsPressed[9]; data.leftStickButton = js.buttonsPressed[9];
data.rightStickButton = js.buttonsPressed[10]; 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); topicPrx->reportGamepadState(deviceName, js.name, data, nowTimestamp);
......
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