GamepadUnit.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::GamepadUnit
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#include <fcntl.h>
26#include <sys/stat.h>
27
32
33#include <RobotAPI/interface/units/GamepadUnit.h>
34
35#include "Joystick.h"
36#include <linux/joystick.h>
37
38namespace armarx
39{
40 /**
41 * @class GamepadUnitPropertyDefinitions
42 * @brief
43 */
45 {
46 public:
49 {
50 //defineRequiredProperty<std::string>("PropertyName", "Description");
51 //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
53 "GamepadTopicName", "GamepadValues", "Name of the Gamepad Topic");
55 "GamepadDeviceName", "/dev/input/js2", "device that will be opened as a gamepad");
57 "GamepadForceFeedbackName",
58 "",
59 "device that will be used for force feedback, leave empty to disable. See "
60 "RobotAPI/source/RobotAPI/drivers/GamepadUnit/README.md for more details.");
62 "PublishTimeout",
63 2000,
64 "In Milliseconds. Timeout after which the gamepad data is not published after, if "
65 "no new data was read from the gamepad");
66 }
67 };
68
69 /**
70 * @defgroup Component-GamepadUnit GamepadUnit
71 * @ingroup RobotAPI-Components
72 * A description of the component GamepadUnit.
73 *
74 * @class GamepadUnit
75 * @ingroup Component-GamepadUnit
76 * @brief Brief description of class GamepadUnit.
77 *
78 * Detailed description of class GamepadUnit.
79 */
80 class GamepadUnit : virtual public armarx::Component, virtual public GamepadUnitInterface
81 {
82 public:
83 /**
84 * @see armarx::ManagedIceObject::getDefaultName()
85 */
86 std::string
87 getDefaultName() const override
88 {
89 return "GamepadUnit";
90 }
91
92 protected:
93 /**
94 * @see armarx::ManagedIceObject::onInitComponent()
95 */
96 void onInitComponent() override;
97
98 /**
99 * @see armarx::ManagedIceObject::onConnectComponent()
100 */
101 void onConnectComponent() override;
102
103 /**
104 * @see armarx::ManagedIceObject::onDisconnectComponent()
105 */
106 void onDisconnectComponent() override;
107
108 /**
109 * @see armarx::ManagedIceObject::onExitComponent()
110 */
111 void onExitComponent() override;
112
113 /**
114 * @see PropertyUser::createPropertyDefinitions()
115 */
117
119
120 void vibrate(const ::Ice::Current& = ::Ice::emptyCurrent) override;
121
122 private:
123 GamepadUnitListenerPrx topicPrx;
126
127 void run();
128 std::mutex mutex;
129 std::string deviceName;
130 std::string deviceEventName;
131 Joystick js;
132 GamepadData data;
133 TimestampVariantPtr dataTimestamp;
134 };
135} // namespace armarx
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
GamepadUnitPropertyDefinitions(std::string prefix)
Definition GamepadUnit.h:47
Brief description of class GamepadUnit.
Definition GamepadUnit.h:81
void onInitComponent() override
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
void vibrate(const ::Ice::Current &=::Ice::emptyCurrent) override
void onExitComponent() override
std::string getDefaultName() const override
Definition GamepadUnit.h:87
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
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)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< TimestampVariant > TimestampVariantPtr