From 400cee7361d827115497bc2b1b10ba8dc34a8afb Mon Sep 17 00:00:00 2001 From: Markus Grotz <Markus Grotz markus.grotz@kit.edu> Date: Thu, 28 May 2020 16:02:44 +0200 Subject: [PATCH] add emergency stop to gamepad --- .../GamepadControlUnit/GamepadControlUnit.cpp | 11 ++++++++++- .../GamepadControlUnit/GamepadControlUnit.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp index 57bd492d1..5c413bf4d 100644 --- a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp +++ b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.cpp @@ -26,6 +26,8 @@ + + namespace armarx { void GamepadControlUnit::onInitComponent() @@ -33,12 +35,14 @@ namespace armarx ARMARX_INFO << "oninit GamepadControlUnit"; usingProxy(getProperty<std::string>("PlatformUnitName").getValue()); usingTopic(getProperty<std::string>("GamepadTopicName").getValue()); - + usingProxy("EmergencyStopMaster"); scaleX = getProperty<float>("ScaleX").getValue(); scaleY = getProperty<float>("ScaleY").getValue(); scaleRotation = getProperty<float>("ScaleAngle").getValue(); ARMARX_INFO << "oninit GamepadControlUnit end"; + + } @@ -46,6 +50,7 @@ namespace armarx { ARMARX_INFO << "onConnect GamepadControlUnit"; platformUnitPrx = getProxy<PlatformUnitInterfacePrx>(getProperty<std::string>("PlatformUnitName").getValue()); + emergencyStop = getProxy<EmergencyStopMasterInterfacePrx>("EmergencyStopMaster"); } @@ -68,6 +73,10 @@ namespace armarx void GamepadControlUnit::reportGamepadState(const std::string& device, const std::string& name, const GamepadData& data, const TimestampBasePtr& timestamp, const Ice::Current& c) { + if (data.leftTrigger) + { + emergencyStop->setEmergencyStopState(EmergencyStopState::eEmergencyStopActive); + } //scales are for the robot axis if (data.rightTrigger > 0) { diff --git a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h index 2614a96ff..abdf77a77 100644 --- a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h +++ b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h @@ -24,6 +24,7 @@ #include <ArmarXCore/core/Component.h> +#include <ArmarXCore/interface/components/EmergencyStopInterface.h> #include <RobotAPI/interface/units/GamepadUnit.h> @@ -105,6 +106,7 @@ namespace armarx float scaleX; float scaleY; float scaleRotation; + EmergencyStopMasterInterfacePrx emergencyStop; public: void reportGamepadState(const std::string& device, const std::string& name, const GamepadData& data, -- GitLab