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 
35 namespace 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");
49  defineOptionalProperty<std::string>(
50  "PlatformUnitName", "Armar6IcePlatformUnit", "Name of the platform unit to use");
51  defineOptionalProperty<std::string>(
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");
55  defineOptionalProperty<float>(
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
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
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:41
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:199
armarx::GamepadControlUnit::onDisconnectComponent
void onDisconnectComponent() override
Definition: GamepadControlUnit.cpp:65
HeartbeatComponentPlugin.h
armarx::GamepadControlUnit::getDefaultName
std::string getDefaultName() const override
Definition: GamepadControlUnit.h:80
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::GamepadControlUnitPropertyDefinitions::GamepadControlUnitPropertyDefinitions
GamepadControlUnitPropertyDefinitions(std::string prefix)
Definition: GamepadControlUnit.h:44
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:27
armarx::GamepadControlUnit::onConnectComponent
void onConnectComponent() override
Definition: GamepadControlUnit.cpp:47