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/units/GamepadUnit.h>
30 
31 #include <RobotAPI/interface/units/HandUnitInterface.h>
32 
34 #include <RobotAPI/interface/components/RobotHealthInterface.h>
35 #include <RobotAPI/interface/units/PlatformUnitInterface.h>
36 
37 namespace armarx
38 {
39  /**
40  * @class GamepadControlUnitPropertyDefinitions
41  * @brief
42  */
45  {
46  public:
49  {
50  //defineRequiredProperty<std::string>("PropertyName", "Description");
51  //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
52  defineOptionalProperty<std::string>("PlatformUnitName", "Armar6IcePlatformUnit", "Name of the platform unit to use");
53  defineOptionalProperty<std::string>("GamepadTopicName", "GamepadValues", "Name of the Gamepad Topic");
54  defineOptionalProperty<float>("ScaleX", 1000.0f, "scaling factor in mm per second");
55  defineOptionalProperty<float>("ScaleY", 1000.0f, "scaling factor in mm per second");
56  defineOptionalProperty<float>("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  */
72  virtual public armarx::Component,
73  virtual public GamepadUnitListener
74  {
75  public:
77 
78  /**
79  * @see armarx::ManagedIceObject::getDefaultName()
80  */
81  std::string getDefaultName() const override
82  {
83  return "GamepadControlUnit";
84  }
85 
86  protected:
87  /**
88  * @see armarx::ManagedIceObject::onInitComponent()
89  */
90  void onInitComponent() override;
91 
92  /**
93  * @see armarx::ManagedIceObject::onConnectComponent()
94  */
95  void onConnectComponent() override;
96 
97  /**
98  * @see armarx::ManagedIceObject::onDisconnectComponent()
99  */
100  void onDisconnectComponent() override;
101 
102  /**
103  * @see armarx::ManagedIceObject::onExitComponent()
104  */
105  void onExitComponent() override;
106 
107  /**
108  * @see PropertyUser::createPropertyDefinitions()
109  */
111 
112  private:
113  PlatformUnitInterfacePrx platformUnitPrx;
114 
115  plugins::HeartbeatComponentPlugin* heartbeatPlugin = nullptr;
116 
117 
118 
119  bool enableHeartBeat = false;
120  float scaleX;
121  float scaleY;
122  float scaleRotation;
123  EmergencyStopMasterInterfacePrx emergencyStop;
124 
125  bool leftHandOpen = true;
126  bool rightHandOpen = true;
127 
128  long leftHandTime = 0;
129  long rightHandTime = 0;
130 
131  public:
132  void reportGamepadState(const std::string& device, const std::string& name, const GamepadData& data,
133  const TimestampBasePtr& timestamp, const Ice::Current& c) override;
134 
135  };
136 }
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::GamepadControlUnit::onInitComponent
void onInitComponent() override
Definition: GamepadControlUnit.cpp:33
armarx::plugins::HeartbeatComponentPlugin
Definition: HeartbeatComponentPlugin.h:33
armarx::GamepadControlUnit::reportGamepadState
void reportGamepadState(const std::string &device, const std::string &name, const GamepadData &data, const TimestampBasePtr &timestamp, const Ice::Current &c) override
Definition: GamepadControlUnit.cpp:87
armarx::GamepadControlUnitPropertyDefinitions
Definition: GamepadControlUnit.h:43
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::GamepadControlUnit::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: GamepadControlUnit.cpp:76
armarx::GamepadControlUnit::onExitComponent
void onExitComponent() override
Definition: GamepadControlUnit.cpp:70
armarx::GamepadControlUnit::GamepadControlUnit
GamepadControlUnit()
Definition: GamepadControlUnit.cpp:202
armarx::GamepadControlUnit::onDisconnectComponent
void onDisconnectComponent() override
Definition: GamepadControlUnit.cpp:65
HeartbeatComponentPlugin.h
armarx::GamepadControlUnit::getDefaultName
std::string getDefaultName() const override
Definition: GamepadControlUnit.h:81
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::GamepadControlUnitPropertyDefinitions::GamepadControlUnitPropertyDefinitions
GamepadControlUnitPropertyDefinitions(std::string prefix)
Definition: GamepadControlUnit.h:47
armarx::GamepadControlUnit
Brief description of class GamepadControlUnit.
Definition: GamepadControlUnit.h:71
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::GamepadControlUnit::onConnectComponent
void onConnectComponent() override
Definition: GamepadControlUnit.cpp:47