GamepadControlUnit.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotAPI::ArmarXObjects::GamepadControlUnit
17 * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu )
18 * @date 2017
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25
27#include <ArmarXCore/interface/components/EmergencyStopInterface.h>
28
29#include <RobotAPI/interface/components/RobotHealthInterface.h>
30#include <RobotAPI/interface/units/GamepadUnit.h>
31#include <RobotAPI/interface/units/HandUnitInterface.h>
32#include <RobotAPI/interface/units/PlatformUnitInterface.h>
34
35namespace armarx
36{
37 /**
38 * @class GamepadControlUnitPropertyDefinitions
39 * @brief
40 */
42 {
43 public:
46 {
47 //defineRequiredProperty<std::string>("PropertyName", "Description");
48 //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
50 "PlatformUnitName", "Armar6IcePlatformUnit", "Name of the platform unit to use");
52 "GamepadTopicName", "GamepadValues", "Name of the Gamepad Topic");
53 defineOptionalProperty<float>("ScaleX", 1000.0f, "scaling factor in mm per second");
54 defineOptionalProperty<float>("ScaleY", 1000.0f, "scaling factor in mm per second");
56 "ScaleAngle", 1.0f, "scaling factor in radian per second");
57 }
58 };
59
60 /**
61 * @defgroup Component-GamepadControlUnit GamepadControlUnit
62 * @ingroup RobotAPI-Components
63 * A description of the component GamepadControlUnit.
64 *
65 * @class GamepadControlUnit
66 * @ingroup Component-GamepadControlUnit
67 * @brief Brief description of class GamepadControlUnit.
68 *
69 * Detailed description of class GamepadControlUnit.
70 */
71 class GamepadControlUnit : virtual public armarx::Component, virtual public GamepadUnitListener
72 {
73 public:
75
76 /**
77 * @see armarx::ManagedIceObject::getDefaultName()
78 */
79 std::string
80 getDefaultName() const override
81 {
82 return "GamepadControlUnit";
83 }
84
85 protected:
86 /**
87 * @see armarx::ManagedIceObject::onInitComponent()
88 */
89 void onInitComponent() override;
90
91 /**
92 * @see armarx::ManagedIceObject::onConnectComponent()
93 */
94 void onConnectComponent() override;
95
96 /**
97 * @see armarx::ManagedIceObject::onDisconnectComponent()
98 */
99 void onDisconnectComponent() override;
100
101 /**
102 * @see armarx::ManagedIceObject::onExitComponent()
103 */
104 void onExitComponent() override;
105
106 /**
107 * @see PropertyUser::createPropertyDefinitions()
108 */
110
111 private:
112 PlatformUnitInterfacePrx platformUnitPrx;
113
114 plugins::HeartbeatComponentPlugin* heartbeatPlugin = nullptr;
115
116
117 bool enableHeartBeat = false;
118 float scaleX;
119 float scaleY;
120 float scaleRotation;
121 EmergencyStopMasterInterfacePrx emergencyStop;
122
123 bool leftHandOpen = true;
124 bool rightHandOpen = true;
125
126 long leftHandTime = 0;
127 long rightHandTime = 0;
128
129 public:
130 void reportGamepadState(const std::string& device,
131 const std::string& name,
132 const GamepadData& data,
133 const TimestampBasePtr& timestamp,
134 const Ice::Current& c) override;
135 };
136} // namespace armarx
std::string timestamp()
constexpr T c
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void reportGamepadState(const std::string &device, const std::string &name, const GamepadData &data, const TimestampBasePtr &timestamp, const Ice::Current &c) override
std::string getDefaultName() const override
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.